. NET Common face questions

Source: Internet
Author: User
Tags how to prevent sql injection how to prevent sql injection attacks instance method xsl xslt

Interview Question 1 What is the CTS, CLS, and CLR

The common language runtime (CLR) is an implementation of the CLI that contains the. NET run engine and the class library conforming to the CLI.
The common type System (CTS) contains the CLI specification submitted by Microsoft Corporation, which defines a type specification that can be run on the CLR.
The common language specification is a subset of the CTS that defines the minimum set of specifications that all of the. NET-oriented programs need to conform to.

Interview 2 Comparison of CLR technology and COM technology
Both the CLR and COM define specifications for interaction between components. COM does not define how to describe dependencies between components, and because of its strict physical conventions, it causes many component version upgrades and control issues. The CLR uses such mechanisms as metadata and logical type definitions to effectively solve some of the problems that COM has left behind. And, compared to the COM model, I think the CLR is easier to understand and learn.

Interview question 3 how JIT works
Before compiling the intermediate code, the JIT engine looks for the method's native machine code cache and determines whether it is available, if it is available directly, if it is unavailable, the JIT engine looks for the method stub in the type, finds the intermediate code, and compiles it.

Interview 4 How to put an assembly into the GAC
The GAC is a folder with a specific directory structure, and all strongly signed assemblies can be placed in the GAC. You can simply drag to add an assembly to the GAC through the. NET Framework's Assembly Viewer, or you can use a command line to add it using tools such as Gacutil.exe. In summary, any method, in the final analysis, is based on the GAC's specifications and the characteristics of the Assembly itself, creating the corresponding subdirectory structure in the GAC directory.

Interview questions 5 differences between value types and reference types
All types that inherit from System.ValueType are value types, and other types are reference types. Assigning a value type results in a new copy of the data, so each value type has a copy of the data, and the assignment of the reference type is an assignment reference. Objects of value types are allocated on the stack, whereas objects of reference types are allocated on the heap. When comparing two value types, a comparison of the content is made, and a reference comparison is made when comparing two reference types.

Interview 6 What is the difference between a string and a string in C #
String and string are two names of the same type, with the same case as object and object. In addition to the name, there is no difference between the two.
Interview question 7 briefly. The features and differences of the stack and heap in net. NET programs allocate stacks, managed heaps, and unmanaged heaps in process memory. All references to value-type objects and reference-type objects are allocated on the stack, and the stacks are allocated and deallocated according to the lifetime of the object, and the stack allocates memory based on a pointer to the tail of the stack, which is more efficient.
. NET all reference-type objects are allocated on the managed heap, the managed heap allocates memory continuously, and is managed by the. NET garbage collection mechanism, where memory allocation and deallocation by the managed heap involves complex memory management, which is much less efficient than the stack. unmanaged types that need to allocate heap memory are allocated on the unmanaged heap and unmanaged heaps are not managed by the. NET garbage collection mechanism, and the blocks of memory are completely manually applied and released by the programmer.

Interview question 8. The operation mechanism of GC in net
Garbage collection refers to collecting the freed object memory that is no longer being used on the managed heap. The process basically consists of finding an object that is no longer being used by the algorithm, moving the object so that all the objects that are still being used are on the side of the managed heap, and adjusting each state variable. The running cost of garbage collection is higher, which has great effect on performance. When programmers write. NET code, they should avoid unnecessary memory allocations and minimize or avoid using GC. Collect to perform garbage collection.

Interview 9 briefly describe the concepts of overriding, overloading, and hiding in C #
Overrides are the use of the override keyword to re-implement a virtual method in a base class, in which the method of the real object type is called, regardless of the type of reference passed. Shadowing is the re-implementation of a method in a base class with the New keyword, which determines which type of method should be called by the type referenced during the run. Overloading means that multiple methods share the same name and have the same return value, but can have different parameter lists.

Interview question 10 How to declare a class in C # cannot be inherited
C # by keyword: Sealed can declare that a type cannot be inherited, and the design should add sealed keywords to all types that are not used as base classes in order to avoid the various errors that arise from inheritance.

Interview questions Int[] is a reference type or a value type
Array types are family types, all of which inherit from System.Array, and System.Array inherit from System.Object. All array types are reference types.

Interview question 12 explaining the fundamentals of generics
Generics are similar to templates in C + +, allowing programmers to define more general types and algorithms, and then generate concrete enclosing types when they are used. All types with generic parameters are an open type, which cannot be instantiated, but have other attributes of all enclosing types, which in essence do not differ from the enclosing type.

What is the role of the Serializable feature in interview questions
By adding the serialization attribute to a type, you can declare the object to be serializable, or it can be serialized and deserialized by objects of a type such as Binaryformmater.

Interview question 14 How to customize the process of serialization and deserialization
Custom serialization can be achieved by implementing the GetObjectData method in the ISerializable interface, and the process of deserialization can be customized by adding a constructor with SerializationInfo and StreamingContext parameters.

Interview 15 How to use the IFormattable interface to implement formatted output
The IFormattable interface help type implements multi-style formatted output. The ToString method of IFormattable accepts a string parameter representing the format, which is formatted by parsing the parameter. In addition, the IFormattable.ToString method accepts a parameter of type IFormatProvider to allow the consumer of the type to provide a formatted method.

Interview question 16. NET provides a few timer types
There are three timer types in. NET built-in types, namely:

    1. ? System.Windows.Forms.Timer type
    2. ? System.Threading.Timer type
    3. ? System.Timers.Timer type

Interview question 17 What are the similarities and differences between the three comparison methods defined in System.Object
The static method ReferenceEquals implements a reference comparison. The static Equals method implements the ability to invoke an instance of the Equals method more efficiently. The instance equals method is a virtual method, the default implementation is a reference comparison, and the type can override the instance of the Equals method as needed. The base class of the value type ValueType overrides the Equals method to achieve a comparison of the content.

Interview 18 Please explain the rationale of the Commission
A delegate is a class of types that inherit from System.Delegate, and each delegate object contains at least one pointer to a method, either an instance method or a static method. Delegates implement the mechanism of callback methods to help programmers design more concise and graceful object-oriented programs.

Interview question 19 What is the difference between a delegate callback static method and an instance method
When a delegate binds a static method, the internal object member variable: _target will be set to NULL, and when the delegate binds an instance method, _target sets exponentially to an instance object of the type to which the instance method belongs, and when the delegate is executed, the object instance is used to invoke the instance method.

Interview question 20 What is a chained delegate
A chained delegate is a linked list that is strung by a delegate, and subsequent delegates to that delegate on all linked lists are executed sequentially when a delegate on the list is called back.

Interview Question 21 Please explain the basic use of the event
An event is a member that enables an object or class to provide notification. The client can add executable code for the corresponding event by providing an event handler. An event is a special kind of delegate.

Interview 22 Please explain the fundamentals of reflection and the cornerstone of its implementation
Reflection is a mechanism for dynamically analyzing target objects such as assemblies, modules, types, and fields, and its implementation is based on meta-data. Metadata is a block of data stored in a PE file that details the structure inside the assembly or module, the type of reference, and the assembly and manifest.

Interview question 23 How to use reflection to implement Factory mode
Using reflection allows for a more flexible factory model, the key is to dynamically find all the parts contained in the product, without the need for code to analyze the needs of the user individually. The reflective plant model features a high level of flexibility and a relatively low operating efficiency.

Interview 24 How to save Type, Field, and Method information at a small memory cost
System.runtimetypehandle, System.runtimemethodhandle, and System.runtimefieldhandle have three types, each containing a pointer to the type, method, and field description. Saving pointers is a useful way to reduce memory consumption by replacing information-describing objects that hold the entire type, method, and field. When this information is actually needed, the System.Type, System.Reflection.MethodInfo, and System.Reflection.FieldInfo type objects can be obtained by using these three handle type objects respectively.

Interview question 25 What is a thread
Threads are the concept of lightweight threading proposed by Microsoft, a thread that has its own stack and register state. A thread can contain multiple threads, and the thread is scheduled by the operating system differently, the thread's scheduler is completely controlled by the programmer itself, and the kernel of the operating system does not know the existence of the thread at all. In the. NET schema, the concept of threads does not necessarily correspond to the threads of the operating system, and in some cases threads in. NET correspond to one thread.

Interview question 26 How to use. NET's thread pool
The System.Threading.ThreaPool type encapsulates the operation of the thread pool. Each process has a thread pool, and. NET provides a mechanism to manage threads, and users simply need to insert thread requirements into the thread pool without having to ignore the subsequent work. All threads in the thread pool are background threads, and they do not prevent the program from exiting.

How does the lock keyword in C # work?
The lock keyword in C # is essentially a simplified syntax for invoking the two methods of Monitor.Enter and Monitor.Exit, which allows synchronization of an object to enter and exit. In general, thread synchronization within a member method can be accomplished through the lock of a private reference member variable, while thread synchronization within a static method is accomplished by lock a private static reference member variable.

Interview 28 Please explain the form of ASP.
The ASP. NET is run as an ISAPI filter program, and it is the host of a. NET CLR that implements the functionality of running managed server code.

What is the difference between a GET request and a POST request for an interview question
There are two common requests in the HTTP protocol: GET and post. A GET request places the data of the form in a URI and limits the length and data value encoding. The POST request places the form data in the HTTP request body, and there is no limit to the length.

Interview question 30 introduces ASP. NET page life cycle
If you classify the life cycle steps of an ASP, you can roughly divide it into four categories:

    1. Initialization
    2. Loading data and Pages
    3. Triggering events
    4. Save state and Render page

1) initialize  
Initializes three steps, including the PreInit, Init, and InitComplete listed above, with features such as initializing the class object, initializing the theme's main page, and judging whether it is the initial function such as the first access page.  
2) Load data and page  
This type contains steps such as Loadsate, Processpostdate, preload, load, processpostdata (second), and so on. First the data that is returned from the page is loaded into the ViewState object, and all the data is passed to the server with the BASE64 encoding. It then starts processing the data of the callback, which is the key/value pairs in the form. The page is then loaded, and programmers typically do some initialization programming here, such as writing page initialization code in the OnLoad event. Finally, the processpostdata is executed again to handle the newly added data at load time.  
Description: Two execution of processpostdata is often confusing to programmers, in fact, these two data processing is necessary. The first processing ensures that all data is read from the page before the page is loaded, so that the data can be accessed when the page is loaded. The second processpostdata is to allow the page to load the data in the newly created control to be processed. These two treatments are indispensable.  
3) triggers the event  
The triggering event contains changedevents and postbackevent steps. This first compares the data in the viewstate with the data from the last postback of the page, and finds out which events need to be triggered, where the events are triggered one by one, but the order cannot be determined. It then checks to see if the post back event is triggered, which is the event that the page submits.  
4) Save the State and render the page  
This will contain SaveState, Savestatecomplete, and render steps. First, the page encodes all of the ViewState data and embeds it in a hidden control on the page. It then transforms all the control labels and generates the page HTML and sends it back to the client.  
Note: The above classification does not contain the final Unload step, because although this step is important, it never requires the programmer's concern, and ASP. NET will be responsible for releasing resources for all objects.

Interview 31 list several ways to implement page jumps
In almost every ASP. NET application, there will be a need for page jumps, and there are many ways to implement page jumps:

    1. Using the Response.Redirect method
    2. Using the Server.Transfer method
    3. Using the Server.Execute method
    4. Using JavaScript scripts
    5. Using hyperlinks

Interview question 32 How to prevent SQL injection attacks
An attack method commonly used in SQL injection attacks, which mainly exploits the drawbacks of system design. Programmers need to take into account the problem of injection attack, avoid directly using the user input splicing SQL statements, properly use encrypted data for storage, and use stored procedures in appropriate situations.

Interview question, ADO. What kinds of data sources are supported by net
ADO supports four categories of data sources, namely: SQL Server database, ORACLE database, OLE DB provider, and ODBC provider.

Interview Question 34 Please briefly describe the mechanism of database connection pooling
ADO provides the database connection pool service to the upper-level user, and the database connection that is used is selected to remain in the database connection pool for the next use. When a user requests a connection string for a database connection, the database connection pool will attempt to find a connection in the pool that has the same connection string and provide it directly to the user.

Interview questions 351 What properties can be included in a connection string
The connection string contains a rich set of optional properties that the programmer should lot the database connection string for when doing database operations, and the different settings will suit different realities. For a detailed list of connection string properties, refer to table 1.

Interview questions What is a strongly typed DataSet
A strongly typed dataset is a type of fixed structure that inherits from a DataSet, and a strongly typed DataSet, compared to a dataset, is easy to access and highly restrictive, which facilitates the isolation of the data access layer and facilitates the discovery of errors early in the compilation phase.

Interview questions what is XML
XML is Extensible Markup Language, XML is a simple data storage language, using a series of simple tags to describe the data, and these tags can be built in a convenient way, XML is extremely simple and easy to grasp and use.

Interview questions how namespaces in XML are used
Namespaces are used to modularize elements in XML documents, which are defined in the following form:
Xmlns:namespace-prefix= "namespace". When the parser tries to read a node under a specific namespace, you need to specify the name of the namespace.

Interview questions . NET how to verify the format of an XML document
With the recommendation of the World Wide Organization, XSD has become the most standard and common XML structure definition language. In. NET, Xmsreader supports the use of XSD files to verify that an XML document conforms to a specific format, what the programmer needs to do to set up a Xmlreadersetting object that contains the specified XSD file, and to traverse the XML document.

Interview question What is the role of XSLT,XSLT?
XSLT is a language that formats XML documents by using XPath to extract the required content from an XML document and to organize new formats according to specific syntax.

How to use XSLT documents in your code for the interview question
All XSL-enabled types in. NET are defined under the SYSTEM.XML.XSL namespace and can be converted using XslCompiledTransform for the specified format. In addition, in a BS structural system, the client can invoke the Microsoft.XMLDOM type using JavaScript scripts and format the conversion.

Please describe the SOAP protocol in the interview question
SOAP provides a simple, lightweight mechanism for exchanging structured and type information in a decentralized or distributed environment, in XML form. The SOAP protocol defines how the interaction is done, but does not specify the environmental and technical details of the time-limited protocol. Readers can refer to the SOAP protocol definition document to obtain all the protocol content.

How are the interview questions in. NET to create a Web Service
In. NET, you can use the built-in type WebService and WebMethod attributes to implement Web Service, which allows programmers to focus on logic work without having to deal with communication-related work at all. For greater flexibility, programmers can implement the Ihttprequest interface to achieve the defined ASMX resource request processing type. Further, programmers can customize resource files and handlers to implement fully customized Web Service, just to ensure that all returns conform to the SOAP protocol.

Interview question How to generate a Web Service proxy type
The Web service proxy class refers to the type of proxy that is responsible for SOAP communication, which allows the programmer to access the Web service server by invoking the local Web service proxy type. In. NET, you can generate a Web Service proxy type by using the Wsdl.exe tool or by adding a web citation, which can easily update the proxy type after the server-side has changed.

How to improve the reuse rate of connections within a connection pool
In order to improve the reuse rate of database connection pool, the only way is to ensure that the connection string used by the system to access the database is the same. For example, set up a springboard database so that all connections attempt to access the Springboard database first. In addition, unified use of the Superuser account can further unify the connection string, but this poses a security risk to the system.

The interview question is ADO. NET supports two ways to access a relational database
ADO supports two kinds of database access methods, namely, connected and offline. The connection is more suitable for large data volumes and does not accurately predict how many records need to be read, and the offline type is more suitable for small data volume reading operations.

Interview question What is a relational database
Relational database is a database supporting the use of relational model, in short, the relational model refers to the two-dimensional table model. Compared with other models, relational database has the advantages of easier understanding, easier use and simpler maintenance.

What are the different ways to store an interview question?
There are four ways to store Session data in the IIS process, in the state server, in the SQL Server database, and in the custom program. In addition to preparing the necessary services, such as a SQL Server database server, you also need to configure the site's Web. config file for setup.
Note: You can set the close session data in Web. config so that the session data cannot be saved.

Interview Question 49 Please briefly describe the function and implementation mechanism of ViewState
ViewState is used to store data within a page range to ensure the continuity of data before the user leaves the page. On the implementation, viewstate is stored inside a hidden control within the page and is extracted after it is submitted to the server.

. NET Common face questions

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.