. NET interview questions and Answers (large summary),. NET job seekers should not be missed

Source: Internet
Author: User
Tags abstract eval garbage collection odbc net thread ole sql injection static class

This is my. NET interview question and answer, I hope to be helpful to. NET job seekers, especially to fresh graduates.

Use. NET to do b/s structure of the system, you are using several layers of structure to develop, the relationship between each layer and why this layering?

From bottom to top: Data access layer, business logic layer (or become domain layer), presentation layer
Data Access layer: sometimes known as the persistence layer, its function is mainly responsible for database access
Business Logic Layer: The core of the entire system, it is related to the business (domain) of the system
Presentation layer: The UI part of the system that is responsible for the interaction of the user with the entire system.
Advantages: Clear division of labor, clear, easy to debug, and scalable.
Disadvantage: Increase the cost.

What is the advantage of layered structure?
1, developers can only focus on the entire structure of one of the layers;
2, can be easily replaced by the new implementation of the original level of implementation;
3, can reduce the layer and the dependence between layers;
4, conducive to standardization;
5, conducive to the reuse of the logic of each layer.
Broadly speaking, layered design can achieve the following objectives: distraction, loose coupling, logical reuse, standard definition.

layered structures also inevitably have some drawbacks:
1, reduce the performance of the system. This is self-evident. If you do not use a layered structure, many businesses can visit the database directly to obtain the appropriate data, but now must be done through the middle tier.
2, sometimes lead to cascading changes. This change is especially true in the top-down direction. If you need to add a feature to the presentation layer, to ensure that its design conforms to a layered structure, you may need to add code to the appropriate business logic layer and data access layer.

MVC pattern
MVC (Model-view-controller) decomposes the composition of the interactive system into three components of the model, view, controller

Advantages of MVC:

1. Complex projects are easier to maintain by dividing them into model view and controller.
2. No use of view state and server form controls makes it easier to control the behavior of your application
3. Applications use controller to control the request and can provide rich URL rewriting.
4. Better support for unit testing
5. More Outstanding performance in team Development mode

The lack of MVC:

(1) The complexity of system structure and implementation is increased. For a simple interface, strictly following MVC, separating the model, view, and controller will increase the complexity of the structure and may result in excessive update operations and lower operational efficiency.
(2) Too tight a connection between the view and the controller. The view and controller are separate, but closely connected parts, the view has no controller, its application is very limited, and vice versa, which hinders their independent reuse.
(3) Inefficient access of the view to model data. Depending on the model's operating interface, the view may require multiple calls to obtain sufficient display data. Unnecessary frequent access to unchanged data also impairs operational performance.

asp.net How to implement the MVC pattern, illustrated!
Web/business/dataaccess
Enumerates several ways to pass values between asp.net pages.
1. Use querystring, such as ...? id=1; Response. Redirect () ....
2. Use Session Variables
3. Use of Server.Transfer

explain how to pass parameters between pages that are commonly used in. NET, and say their pros and cons.
QueryString delivers one or more values that are not of high security requirements or are simple in structure. But for passing arrays or objects, you can't use this method. Session (ViewState) simple, but easy to lose the role of users, excessive storage can lead to the depletion of server memory resources. The scope of the Application object is the entire global, which means it works for all users. Its commonly used methods are simple with lock and unlock cookies, but may not be supported, and may be spoofed cookies are stored on the client, while the session is stored on the server side.  And the use of cookies with the ASP.net built-in object request to use the input ttype= "hidden" simple, may be forged URL parameters simple, displayed in the Address bar, length limited Server.Transfer To direct a process from the current page to another page The new page uses the previous page's response stream database is stable, secure, but relatively weak

What is viewstate? How does it work?
ViewState is used to save the page state, that is, after the submission we can also see the contents of the text box is viewstate save the credit.
ViewState only maintains the status of the current page, the session can be shared between different pages.
ViewState you can understand as a hidden control.

ASP. NET page life cycle
The life cycle of each page is the user's every visit, that is, a roundtrip process between the client and the server. The lifecycle of a global variable is between this.
1. Page_Init ();
2. Load ViewState and postback data;
3. Page_Load ();
4. Handle control events;
5. Page_PreRender ();
6. Page_render ();
7. Unload event;
8. Dispose method called;

What are the objects commonly used in ado.net? Describe each.
Connection Open a database connection
command to execute database commands
DataAdapter connect data, execute database commands, populate dataset
DataSet data in memory cache, data structure
DataReader read-Only forward reading database

similarities and differences of DataReader and dataset
DataReader always occupy SqlConnection when used, online operation database. Any action on SqlConnection throws a DataReader exception. Because DataReader only loads one piece of data in memory at a time, the memory footprint is small. Because of the particularity and high performance of DataReader, so DataReader is only in. You can't read the first one after you read the first one.
A dataset is a one-time load of data in memory. Discard database Connections ... The database connection is discarded when read is complete. Because the dataset loads all the data in memory. So it consumes more memory ... But it's more flexible than DataReader. You can dynamically add rows, columns, and data. Return update operation on database ...


advantages and disadvantages of stored procedures and SQL statements
Advantages:
1. Improve performance, reduce network transmission, save time.
2. Reduce network traffic stored procedures are located on the server, when invoked only to pass the name of the stored procedure and parameters, without each access to pass a very long SQL statements.
4. Security reduces SQL injection attacks.
5. maintainability high update stored procedures typically require less time and effort than changing, testing, and redeploying assemblies.
Disadvantages:
1. Poor interaction.
2. Poor portability

say what you know about the database access component (for example, ADO, at least 4 kinds)
ADO,ADO.NET,MDAC (Microsoft Data Access components), Microsoft SQL Server OLE DB Provider,
Microsoft Jet OLE DB provider,desktop Database Drivers ODBC driver,visual FoxPro ODBC Driver

what is Object-oriented
Everything is an object, its main characteristics: encapsulation, inheritance, polymorphism

How to achieve polymorphism
1. When you call a member function directly from an object, the member function of the class of that object is always used by default (unless: Displays the specified class name).
2. When calling a member function by pointing to an object's pointer or reference: If the function is a real function, call the member function of the pointer or the referenced class, or the member function of the class of the object to which the pointer or reference is invoked if the function is a virtual function.

What is the main object oriented idea?
Everything can be understood as an object, its main characteristics: inheritance. Packaging. Polymorphism. Features: Good code maintenance, security, hidden information

what are boxes and unboxing?
Converts from a value type interface to a reference type boxing. Convert from reference type to value type unboxing. Boxing (boxing) is the conversion of value type data to reference type, int i=3; Object o = i; is the boxing process, and the unboxing (unboxing) is the type of data to be consumed, such as int j = (int) o;


what is interface? What is the difference between it and abstract class?
An interface (Interface) is used to define a behavior specification that does not have a specific implementation, while an abstract class can be partially implemented in addition to defining a behavior specification, but a class can implement more than one interface, but can only inherit a parent class

When to use abstract classes, when to interface with
Interfaces are used for specifications, and abstract classes are used for commonality. Only methods, properties, events, indexers can be declared in an interface. In an abstract class, you can have a method implementation, or you can define a non-static class variable. Abstract classes are classes, so they can only be inherited, but interfaces can be implemented multiple at a time. Abstract classes can provide partial implementations of some methods, and interfaces cannot. An instance of an abstract class is given by its subclasses. An instance of an interface is given by the class that implements the interface. If you add a method to the abstract class, the subclass of it has the same method. And adding a new method to the interface, the class that implements it is rewritten (which is why the interface is a specification of a class). Interface members are defined as public, but members of an abstract class can also be private, protected, internal, or protected internal members (in which protected internal members can only be accessed in the application's code or derived classes). In addition, an interface cannot contain fields, constructors, destructors, static members, or constants.

what is an abstract class?
A class that cannot be instantiated. Abstract classes generally contain abstract methods, and of course they can be implemented concretely. An inheriting class cannot be instantiated until it has implemented an abstract method of all abstract classes.

When must I declare a class as an abstract class?
When the class contains an abstract method, or the class does not fully implement the abstract method of the parent class.

What is an interface (interface)?
A class that contains only the common abstract methods (public abstract method). These methods must be implemented in subclasses.

Why can't I specify a modifier for a method in an interface?
The methods in the interface are used to define contracts for communication between objects, and it is meaningless to specify that the methods in the interface are private or protected. They default to public methods.

Can I inherit multiple interfaces?
Of course.

So what if there are duplicate method names in these interfaces?
In this case you can decide how to implement. Of course you need to be very careful. However, there is no problem in compiling the link.

What is the difference between an interface and an abstract class?
All methods in an interface must be abstract and cannot specify a method's access modifier. You can have a method implementation in an abstract class, or you can specify a method's access modifier.

Detailed. NET in class and struct similarities and differences!
Classes are reference types that can inherit classes, interfaces, and inheritance, have default constructors, have destructors, can use abstract and sealed, have protected modifiers, and must be initialized with new.
Structs are value types, can only inherit interfaces, cannot be inherited, have no default constructors, can be created, have no destructors, cannot be abstract and sealed, have no protected modifiers, and can be initialized without new.

How to select a structure or class
1. The stack has limited space, and for a large number of logical objects, creating a class is better than creating a struct
2. Structs represent lightweight objects such as dots, rectangles, and colors
For example, if you declare an array that contains 1000-point objects, additional memory is allocated for referencing each object.
In this case, the cost of the structure is lower.
3. Classes are the best choice when it comes to expressing abstractions and multi-level levels of objects
4. In most cases the type is just some data when the structure is the best choice

What are the similarities and differences between the interfaces and classes in C #.
Different
Interfaces cannot be instantiated directly.
An interface does not contain an implementation of a method.
interfaces, classes, and structs can inherit from multiple interfaces. But C # only supports single inheritance: A class can inherit implementations from only one base class.
Class definitions can be split between different source files.
With:
interfaces, classes, and structs can inherit from multiple interfaces.
Interfaces are similar to abstract base classes: Any Non-abstract type that inherits an interface must implement all the members of the interface.
Interfaces can contain events, indexers, methods, and properties.
A class can implement multiple interfaces.

What's the difference between a const and a readonly?
The const keyword is used to declare a compile-time constant, and ReadOnly is used to declare a run-time amount.

What are the characteristics of a class decorated with sealed?
The sealed modifier is used to prevent the derivation of other classes from the decorated class. If a sealed class is specified as the base class for another class, a compile-time error occurs. Sealed classes cannot be abstract classes at the same time. The sealed modifier is primarily used to prevent unintentional derivation, but it can also cause some run-time optimizations. Specifically, because sealed classes never have any derived classes, calls to virtual function members of instances of sealed classes can be converted to non-virtual calls to handle.

Use of virtual functions
1 virtual specifies that a member function is a virtual function, and that virtual is used only in the definition of the class, and that the keyword is not added outside the class.
2 when a member function of a class is defined as a virtual function, the subclass of the function retains the virtual function feature.
3 The subclass overrides this function, the definition can be without the virtual keyword, but the function declaration is exactly the same as the base class! And this declaration is required.
4) is not a pure virtual function, the virtual function of the parent class must be implemented; And if the virtual function of the parent class is set to a pure virtual function, the subclass must be covered and be implemented!

Explain the difference between virtual, sealed, override, and abstract
Virtual declares the keyword of the virtual method, indicating that the method can be overridden
Sealed indicates that the class cannot be inherited
Override methods for overriding base classes
Abstract declares the keyword of an abstraction class and abstract method, the abstract method does not provide implementation, the subclass implements, and the abstract class is not instantiated.

What is the difference between overloading and overriding?
Overloading is the same as the name of the method, the different parameter types, the number of different parameters, and the different parameter order. overwriting provides an implementation of a subclass that alters the behavior of a parent-class method (is an override of a function in a base class).

What does virtual mean in the definition of a method?
Virtual-modified methods can be overridden by quilts

Can you write non-static methods as static methods?
No, the signature of the Overwrite method must be consistent with the signature of the overridden method, except to change the virtual to override.

Can I override a private virtual method?
No, even the private methods in the parent class cannot be accessed in subclasses

Can you prevent a class from being inherited by other classes?
OK, use the keyword sealed

Is it possible to implement a class inheritance without allowing one of the methods to be overwritten?
Can, mark this class as public, and mark this method as sealed.

How do I distinguish overloaded methods?
Different parameter types, number of different parameters, different order of parameters


C # Inheritance:
Base represents an instance of the current object base class (you can call a member of the base class with the base keyword) This represents an instance of the current class
The base and this keyword cannot be used in static methods
Derived classes inherit all members of the base class but constructors and destructors are not inherited
Note If the method of the derived class and the method of the base class have the same name, the method in the base class will be hidden if you need to hide it you can use the keyword new to hide if the new keyword is not written by default processing is hidden although methods with the same name in the base class are hidden but can still be invoked through the base keyword
If the method name of the subclass method is the same as the method name of the base class, the system hides the base class method with the same name and automatically invokes the subclass's method of the same name
The derived class inherits all members of the base class, but cannot show that the calling base class is a member
You cannot call a base class in a derived class with members, such as NUM1,NUM2, but you can implement calling the base class method
Virtual uses a virtual method attribute in the base class to indicate that this method property can override the
Override is used in a derived class to represent an override of a base class virtual method property

A base method that cannot override a non-virtual or static method must be Virtualabstract or override why override can also be overridden because the override in the base class is actually an override of the base class's base class because inheritance is transitive, you can also Override method overrides override declaration cannot change the accessibility of the virtual method override method and virtual method must have the same access level modifier cannot be used with modifiers newstaticvirtual or abstract Modifying the override method overrides a property declaration must specify the exact same access modifier type and name as the inherited property and the overridden property must be virtualabstract or override The token allows the use of the Virtual keyword member variable in the modified static method to allow the use of the virtual keyword attribute to be declared as a virtual property (using the virtual keyword) to override a base class method (overriding a method with the virtual keyword in a method with the same name) overriding and hiding the difference between hiding (the new keyword) is assigning a new memory space rewrite (the override keyword) to a subclass with the same method of a subclass that is placed in a method where the base class has the same name as the same method where the class has the same name. Backward-moving properties can also be overridden


The virtual keyword and the override keyword appear to be in pairs or are syntactically incorrect
Derived classes can stop virtual inheritance by declaring overrides as sealed this requires placing the sealed keyword in front of the override keyword in the class member declaration
You can use the base keyword to call virtual methods in a base class when you override a virtual method in a base class in a subclass


Use base key to access a method with the same name as the base class in a subclass


A reference to a parent class points to an instance of a subclass


Test ts = new Test2 ();

The reference to the parent class points to an instance of the subclass (the method that invokes the subclass)
A reference to a parent class only knows the methods of the parent classes the new method of the subclass can be used to invoke the method of the parent class overridden by the quilt class
A reference to the parent class still goes to the parent class method location to invoke the method of quilt class override if the base class method is declared as virtual and accessed by the override result in the subclass

What are the delegates in C #? is an event a delegate?
A delegate can substitute a method as a parameter into another method. A delegate can be understood to point to a reference to a function. Yes, it's a special kind of delegation.

Heap and Stack in C #
Stacks (stack) are managed by the system, storing code execution and invocation paths, and executing or calling them out of the stack;
The heap (Heap) holds values and objects that remain after the call is completed, and the garbage collector finds that there is no reference to the value or object in the stack, and none is removed from the heap


C # ref differs from out:
1. When using a ref parameter, the incoming parameter must be initialized first. For out, it must be initialized in the method.
2, in the use of ref and out, in the parameters of the method and the method of execution, you have to add the ref or out keyword. To satisfy the match.
3. Out is suitable for use where multiple return values need to be retrun, and ref is used when the caller's reference is modified by the method that needs to be invoked.

Do you know anything about generics? What is the benefit of generics?
Generics: The use of parameterized types to manipulate multiple data types on the same code. Use parameterized types to abstract types to enable flexible reuse
The benefits are-type safety and reduced packing, unpacking. Improve performance, type safety, and quality, and reduce repetitive programming tasks

What are the common base classes for all objects in C #?
System.Object.

How do I implement inheritance in C #?
Add a colon after the class name, plus the name of the base class.

Does C # support multiple inheritance?
Not supported. Can be implemented using interfaces.

Where can the properties/methods modified by protected be accessed?
can be accessed in inheritance or indirect inheritance with subclasses of this class.

Will private members be inherited?
Will, but cannot be accessed. So they seem to be unable to be inherited, but they are indeed inherited.

C # provides a default parameterless constructor, and when I implement another constructor with one argument, I want to preserve this parameterless construct

Create a function. So how many constructors should I write?
Two, once you implement a constructor, C # will no longer provide the default constructor, so you need to manually implement that parameterless constructor.

Describes the access rights for private, protected, public, and internal modifiers.
Private: Privately owned members that are accessible within the class.
Protected: Protects members that are accessible within the class and in inheriting classes.
Public: Publicly members, fully exposed, without access restrictions.
Internal: can be accessed within the same namespace.

Two ways to use new
An instance object that hides the base class method.

. New has several uses
The first type: New Class ();
The second: The method of covering
Public new XXXX () {}
Third: The new constraint specifies that any type parameter in a generic class declaration must have a public parameterless constructor.

What data source 3.datagrid.datasouse can connect to [Dataset,datatable,dataview]

Dataset,datatable,dataview, IList

Class members have () an accessible form of

Accessibility: public, protected, private,internal


Usage of Delegates and events
public delegate void Handels ()//return value is void, no parameters
public event Handels Eventhandels;
His.eventhandels = new Handels (fun);
public void Fun ()
{ }


What is the name of the implied parameter of the set method passing in a property?
Value, whose type is the same as the type declared by the property.

String is a value type or a reference type?
Reference type

What is the difference between a string class and a StringBuilder class? Why in. NET class library to have these 2 classes at the same time? (Jane answered)

StringBuilder is more memory-saving than a string, so StringBuilder a faster string object is immutable. Each time you use one of the methods in the System.String class or when you perform an operation (such as assignment, stitching, and so on), you create a new string object in memory, which requires a new space to be allocated for the new object. and StringBuilder is not. The system overhead associated with creating a new string object can be expensive when you need to perform repeated modifications to the string. If you want to modify a string without creating a new object, you can use the System.Text.StringBuilder class. For example, when you concatenate many strings together in a loop, using the StringBuilder class can improve performance.

In C #, string str = null and string str = "" Try to use text or images to illustrate the differences.
String str = NULL does not allocate memory space to him, and string str = "" Assigns it a memory space with an empty string length.

What are the ASP.net authentication methods? What is the principle of distinction?
Windwos (default) with IIS ... From (form) account .... Passport (Key)

What are the major bugs in the session, and what methods does Microsoft propose to solve them?
It is IIS. Because of the process recycling mechanism, the session is lost when the system is busy, and can be stored in a sate server or SQL Server database but this is slow and cannot capture the end event

What is the ternary operator in C #? :
. Objects that can be traversed by a foreach need to implement the type of () interface or declaration (GetEnumerator) method.
. What's the difference between <%#%> and <%%>?
<%#%> represents a bound data source <%%> is a server-side code block constant

How to get the handle to the current form or control in. NET (C # or vb.net), especially the handle to the control itself (please enumerate)

This (C #) Me (vb.net).

. Can C # perform direct operations on memory?
Under. NET,. NET refers to the garbage collection (GC) feature, which replaces the programmer, but in C #, it is not possible to implement the Finalize method directly, but to call the Finalize () method of the base class in the destructor

Can datetime be null?
Cannot because it is a struct type, the struct belongs to a value type, the value type cannot be null, only the reference type can be assigned null

DateTime.Parse (myString); What's wrong with this line of code?
There is a problem, when the mystring can not meet the time format requirements, will throw an exception, recommend the use of Datetime.tryparse ()

NET's error-handling mechanism is:
Using try->catch->finally structure,

Why don't you advocate catch (Exception)
Try.. Catch affects performance when there is an exception; More specific anomalies, such as ioexeception,outofmemoryexception, should be captured.

catch (Exception e) {throw e;} and catch (Exception e) {throw;} The difference
Throws the exception object that occurred, and the other just throws the exception and does not throw the original exception object.

Error and Exception difference:
Error indicates that recovery is not an impossible but difficult situation with a serious problem. For example, memory overflow. It is impossible to expect the procedure to handle such a situation.
Exception represents a design or implementation problem. That is, it means that if the program is working correctly, it will never happen.

The difference between get and post
When a form is submitted, if method is not specified, the default is GET request, and the data submitted in the form is appended to the URL to separate it from the URL. Alphanumeric characters are sent as is, but spaces are converted to "+", and other symbols are converted to%XX, where XX is the ASCII (or ISO Latin-1) value that the symbol is in 16. A GET request requests that the data submitted be placed in the HTTP request protocol header, while the post-submitted data is placed in the Entity data, and when the Post method is used, the data is not used as part of the URL when the data is transferred, and they are transmitted as a separate entity. Therefore, the POST method is more secure and you can also transfer more data in this way. And the data transmitted by POST is not necessarily text, the get method of transmission must be text.
(1) Get is to obtain data from the server, post is to send data to the server.
(1) At the client, the Get mode submits the data through the URL, the data can be seen in the URL; Post mode, the data is placed in the HTML header to submit.
(2) for Get way, server end uses Request.QueryString to obtain variable value, for post way, server end uses Request.Form to obtain the submitted data.
(2) The data submitted by Get method can only have up to 1024 bytes, while post does not have this limit.
(3) Security issues. As mentioned in (1), when using get, the parameters are displayed on the address bar, and the Post does not. So, if the data is Chinese and is not sensitive, use get, or use post if the user enters data that is not a Chinese character and contains sensitive data.

The difference between the bind and eval functions
Binding expression
<%# Eval ("field name")%>
<%# Bind ("field name")%>
1 Eval One-way binding: data is read-only
Bind bidirectional binding: Data can be changed and returned to the server side, and the server can process the changed data, such as depositing into the database.
2. When you are working on a secondary expression, you must use eval such as <%# eval ("Field name"). ToString (). Trim ()%>
3 Bind the properties of a control, and eval is something else.
For example: <asp:textbox id= "the" "runat=" Server "text= ' <%# Bind (" FirstName ")%> '/>
For example: <td><%# Eval ("ProductID")%></td>

Response.Redirect and Server.Transfer
The requested procedure:
1 browser aspx file request---> Server execution---> encounter response.redirect statement-> server send Response.Redirect address to client side browser---> Browser requests to execute a new address
2 browser aspx file request-> Server execution-> encountered Server.Transfer statement-> Server to new file can see Server.Transfer than Response.Redirect a server sent back and the client again request the process.
Jump object:
1 Response.Redirect can switch to any existing Web page.
2) Server.Transfer can only switch to the same directory or subdirectory of the Web page.
Data confidentiality:
1, after the Response.Redirect address will become the page address after the jump.
2, Server.Transfer after the address unchanged, hidden the new page address and attached to the value of the parameter behind the address. With data confidentiality function. Amount of data passed (the parameters that came with the URL):
1, the Response.Redirect can pass the data to 2KB (that is, address bar the maximum length of address) limit.
2, the transmission of data over 2KB, you must use Server.Transfer.


The difference between Server.URLEncode and Httputility.urldecode
The encoding of the Server.URLEncode is encoded in accordance with the encoding of the local program settings, and Httputility.urlencode is encoded by default in the. NET Utf-8 format.

The difference between static and non-static:
The method and the variable declared with static, do not need to instantiate the class to call;
Two, static, must use the instantiated object to invoke, namely uses the new to instantiate.
For example,
If there is a class people, there is a static method Miaoshu (), and the Calling method is People.misoshu ()
There is a non static method GetName (), the calling method is people p= new people (); P.getname ();

How to implement a connection pool
Make sure that you use the same connection string (same as the connection pool) for each connection, and that only the connection string will work together. If the connection string is not the same, the application does not use the connection pool but instead creates a new connection.
Advantages
The main advantage of using connection pooling is performance. The time it takes to create a new database connection depends primarily on the speed of the network and the distance between the application and the database server (the network), and this process is often a time-consuming process. With the database connection pool, the database connection request can be satisfied directly through the connection pool without having to reconnect the request and authenticate to the database server, thus saving time.
Disadvantages
There may be a number of unused connections in the database connection pool that have been linked to the database (which means waste of resources).
Tips and Hints
1. Create a connection pool when you need a database connection instead of building it in advance. Once you have finished using the connection, close it immediately, and don't wait for the garbage collector to handle it.
2. Ensure that all user-defined transactions are closed before you close the database connection.
3. Do not close all connections in the database, at least one of the connections in the connection pool is available. If memory and other resources are issues that you must consider first, you can turn off all connections and then create a connection pool when the next request arrives.

Connection Pooling FAQ

1. When do I create a connection pool?
Create a connection pool when the first connection request arrives; The connection pool's establishment is determined by the connection character Fu Shilai the database connection. Each connection pool is associated with a different connection string. When a new connection request arrives, a connection is removed from the connection pool if the connection string is the same as the string used by the connection pool, or if it is not the same, a new connection pool is created.
2. When is the connection pool closed?
Closes the connection pool when all connections in the connection pool have been closed.
3. What happens when a connection in a connection pool is exhausted and a new connection request arrives?
When a connection pool has reached its maximum number of connections, a new connection request is placed in the connection queue when a new connection request arrives. When a connection is released to the connection pool, the connection pool assigns the newly freed connection to the queued connection request in the queue. You can call close and Dispose to return the connection to the connection pool.
4. How should I allow connection pooling?
For. NET application, the default is to allow connection pooling. (This means you don't have to do anything for this matter) of course, if you can add Pooling=true to the SqlConnection object's connection string, make sure your application allows the connection pool to be used.
5. How should I prohibit connection pooling?
Ado. NET defaults to allow database connection pooling, if you want to prohibit connection pooling, you can use the following methods:
1 when using the SqlConnection object, add the following content to the connection string: Pooling=false;
2 When using the OleDbConnection object, add the following content to the connection string: OLE DB services=-4;

Improve. NET's performance
1 calling Web services and remote objects asynchronously
Whenever possible, avoid synchronous calls to Web services and remote objects during the processing of a request, because it occupies a worker thread in the asp.net thread pool, which directly affects the Web server's ability to respond to other requests.
2 using appropriate caching policies to improve performance
3 to judge the string, do not use "" comparison.
Avoid
if (strabc!=null && strabc!= "")
{}

Recommended
if (!strabc.isnullorempty)
{}

4 page optimization
5 Close the database connection immediately after use
6 use stored procedures as much as possible and optimize query statements
7 read-only data access with SqlDataReader, do not use dataset

..........


. The similarities and differences between UDP and TCP connections
A: The former is transmitted, regardless of the data, no need to establish a connection. The latter ensures that the data transmitted is accurate and needs to be connected.

Please explain the difference between forwarding and jumping
Forwarding is the service side of the jump a page submit data to B page, b page processing and then jump from the server to other pages
Jump is to refer to the client's jump

Describe your understanding of the principles of XML Web service?
A: Use SOAP (Simple Object Access Protocol) to execute remote method calls on HTTP, or you can use the WSDL (Web Service Description Language) to

Complete the Description Web service and then use UDDI to register the services provided by each service provider to share them.

What is an application domain?
A: Application domains can be understood as a lightweight process. Play a role in security. The resource is small to occupy.

What are the CTS, CLS, and CLR interpreted separately?
A: CTS: Universal language System. CLS: Common Language Specification. CLR: Common language runtime.

What is a regulated code?
Answer: unsafe: Unmanaged code. Does not run through the CLR.

What is a strongly typed system?
Answer: RTTI: Type recognition system.
What is Code-behind technology
Codebehind refers to the separation of code and user interface
ASPX and CS

In. NET, what does the accessory mean?
Answer: Assembly. (intermediate language, source data, resources, assembly list)

What are the common methods of calling WebService?
A: 1. Use the WSDL.exe command line tool.
2. Use the Add Web Reference menu option in Vs.net

NET Remoting What is the working principle?
A: Server-side sends a process number to the client, a program field number to determine the location of the object.
The principle of O/R Mapping
A: Using reflection, configure the mapping of objects and database tables

Remoting and WebService two technology understanding and practical application.
A: WS is primarily available to use HTTP to penetrate firewalls. and remoting can use TCP/IP, binary transmission to improve efficiency.

Out reserved words how to use, when to use
A: Sometimes in order to return multiple values from a function, we need to use the Out keyword to assign the output value to a variable (that is, a parameter) passed to the method by reference. But C # requires that variables be initialized before they are referenced. You also need to add the Out keyword when calling this method

What is a PDB? Where should it be placed in debugging?
The PDB is a file for saving debugging and project state information, and will produce PDB files at debug time and should be placed in the same directory as the corresponding application set.


What is the difference between an XML Web service using ASMX and a. NET remoting using SOAP?
The message mechanism used by the Web service, and the RPC used by remoting. Web service can be used on different platforms, different languages, remoting only for. Net. More efficient remoting than XML Web Service

Call Assembly.Load static reference or dynamic reference?
Dynamic

List the XML technologies you know and their applications
Answer: Save the configuration, station and station communication, WEB SERVICE. As well as data interaction with the database, and so on where to use it.

7. How to understand a delegate?
For:
Corresponds to a function pointer, which defines a delegate to invoke that method without invoking the original method name.
Delegates have the following characteristics:
A delegate is similar to a C + + function pointer, but it is type-safe.
A delegate allows a method to be passed as a parameter.
Delegates can be used to define callback methods.
Delegates can be linked together; For example, you can call multiple methods on an event.
method does not require an exact match to the delegate signature. For more information, see Covariance and contravariance.
C # version 2.0 introduces the concept of anonymous methods, which allow code blocks to be passed as parameters in place of a separately defined method.

Overview of Reflection and serialization
Reflection: An assembly contains a module, and a module contains a type, and a type contains a member. Reflection provides an object that encapsulates assemblies, modules, and types. You can use reflection to dynamically create an instance of a type, bind a type to an existing object, or get a type from an existing object. You can then call a type's method or access its field and property serialization: Serialization is the process of converting an object to an easily transmitted format. For example, you can serialize an object and then use HTTP to transfer the object between the client and the server over the Internet. At the other end, deserialization reconstructs the object from that stream.

How does the XmlSerializer work? What ACL permissions are required for processes that use this class?
All I know is that the XmlSerializer is serialized and deserialized of the object's properties and fields, serialized as XML data, deserialized, and then transformed into an object. You should need at least Read permissions in the ACL permissions.

XmlSerializer what is the benefit of the pattern used for attributes? What's the problem?
Serializes only useful data, rather than serializing the entire object. Achieve unnecessary data redundancy and improve performance when serialized.

26. Based on the knowledge of the delegate (delegate), complete the code snippet in the following user controls:
Namespace test
{
public delegate void Ondboperate ();
public class UserControlBase:System.Windows.Forms.UserControl
{
public event Ondboperate OnNew;
Privatevoidtoolbar_buttonclick (Objectsender,system.windows.forms.toolbarbuttonclickeventargs e)
{
if (E.button.equals (btnnew))
{
Please use the following completion code to invoke the OnNew event of the Ondboperate delegate signature.
}
}
}
Answer: if (onnew!= null)
OnNew (this, e);

27. Analyze the following code and complete the blanks.
String strtmp = "ABCDEFG a so-and-so";
int i= System.Text.Encoding.Default.GetBytes (strtmp). Length;
int j= strtmp.length;
After the above code executes, i= j=
Answer: i=13,j=10

28.SQLSERVER server, the given table table1 has two field IDs, Lastupdatedate,id represents the updated transaction number, lastupdatedate indicates the server time when the update, please use a SQL statement to get the last updated transaction number
Answer: Select ID from table1 Where lastupdatedate = (select MAX (lastupdatedate) from table1)

29. Based on the knowledge of thread safety, analyze the following code to see if the i>10 when the test method is invoked will cause a deadlock? and briefly explain why.
public void Test (int i)
{
Lock (This)
{
if (i>10)
{
i--;
Test (i);
}
}
}
A: There is no deadlock, (but there is a point int is passed by value, so each change is just a copy, so there is no deadlock.) But if an int is changed to an object, then the deadlock will occur.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.