. NET Common interview questions,. net questions

Source: Internet
Author: User
Tags how to prevent sql injection how to prevent sql injection attacks net thread xslt

. NET Common interview questions,. net questions

Interview question 1 What are CTS, CLS, and CLR

The Common Language Runtime Library (CLR) is an implementation of CLI, including the. NET runtime engine and a class library conforming to CLI.
The general type System (CTS) includes the CLI specification submitted by Microsoft, which defines a type specification that can run on CLR.
The common language specification is a subset of CTS and defines the minimum specification set that all. NET-oriented programs need to comply.

 

Interview question 2 Comparison of CLR and COM Technologies
Both CLR and COM define the specification for interaction between components. COM does not define how to describe dependencies between components, and due to its strict physical conventions, many component version upgrades and control problems are caused. CLR uses metadata and logical type definitions to effectively solve some issues left over from COM. In addition, compared with the COM model, the author believes that CLR is easier to understand and learn.


Interview question 3 How JIT works
Before compiling the intermediate code, the JIT engine searches for the local machine code cache of the method and determines whether it is available. If it is available, it loads the method directly. If it is unavailable, the JIT engine searches for method stubs of the type, finds the intermediate code, and compiles the code.


Interview question 4 how to put the Assembly in GAC
GAC is a folder with a specific directory structure. All strongly-Signed assemblies can be placed in GAC. You can drag an assembly to GAC by using the assembly viewer that comes with the. NET Framework. You can also use tools such as gacutil.exe to add an assembly. In short, all methods are based on the GAC specifications and the characteristics of the Assembly, and the corresponding subdirectory structure is established under the GAC directory.


Differences between value types and reference types in interview question 5
All types inherited from System. ValueType are value types, while other types are reference types. The Value Type assignment generates a new data copy, so each value type has a data copy, and the value assignment of the reference type is a value reference. Objects of the value type are allocated to the stack, and objects of the reference type are allocated to the stack. When comparing two value types, compare the content, and compare the two reference types, compare the reference.

What is the difference between string and String in interview question 6 C #?
String and string are two names of the same type. In the same case, there are objects and objects. There is no difference except the name.
Interview question 7 briefly describes the features and differences between stacks and stacks in. NET. NET programs allocate stacks, managed heaps, and unmanaged heaps in the process memory. All references of value-type objects and reference-type objects are allocated on the stack. stacks are allocated and released in sequence based on the object's lifecycle, the stack allocates memory based on a pointer pointing to the end of the stack, which is more efficient.
.. NET all reference type objects are allocated on the managed stack. The managed stack continuously allocates memory and receives.. NET garbage collection mechanism management. Memory Allocation and release of managed heaps involve complex memory management, with much lower efficiency than stack. The unmanaged type of heap memory to be allocated will be allocated to the unmanaged heap. the unmanaged heap is not managed by the. NET garbage collection mechanism, and the memory block is manually applied and released by the programmer.

How GC works in interview question 8. NET
Garbage collection is used to collect and release the memory of objects that are no longer used on the hosting stack. The process includes finding out the objects that are no longer in use through algorithms, moving the objects so that all the objects that are still in use are close to the side of the managed heap, and adjusting various state variables. The garbage collection operation cost is high, which has a great impact on performance. When writing. NET code, programmers should avoid unnecessary memory allocation and minimize or avoid using GC. Collect for garbage collection.


Interview question 9 briefly describes the concepts of C # rewriting, overloading, and hiding
Rewriting refers to re-implementing the virtual method in the base class with the override keyword. During the running process, no matter which type of reference is passed, the method of the real object type will be called. Hiding refers to re-implementing the methods in the base class with the new Keyword. During the running process, the referenced type is used to determine which type of method should be called. Overload means that multiple methods share the same name and have the same return value, but they can have different parameter lists.


Interview question 10 how to declare in C # That a class cannot be inherited
In C #, you can use the Keyword: sealed to declare that a type cannot be inherited. In the design, you should add the sealed keyword for all types not used as the base class, to avoid all kinds of errors that are easily generated from inheritance.

 

Interview question 11 Int [] is reference type or value type
Array types are family types. They all inherit from System. Array, while System. Array inherits from System. Object. All array types are reference types.
 
Interview question 12 explain the basic principles of generics
The generic type is similar to the template in C ++. It allows programmers to define more common types and algorithms, and generate specific closed types when using them. All types with generic parameters are open types. They cannot be instantiated, but have other features of all closed types. Essentially, they are no different from closed types.


Interview question 13: What is the function of Serializable?
By adding the Serialization feature for the type, you can declare the object to be serialized, that is, it can be serialized and deserialized by objects such as BinaryFormmater.


Interview question 14 how to customize the serialization and deserialization Process
You can implement custom serialization by implementing the GetObjectData method in the ISerializable interface, and you can customize the deserialization process by adding a constructor with parameters of SerializationInfo and StreamingContext.


Interview question 15 how to use the IFormattable interface to format the output
The IFormattable interface helps you implement formatted output. The ToString method of IFormattable accepts a string parameter that represents the format and formatted the output by analyzing this parameter. In addition, the IFormattable. ToString method accepts an IFormatProvider type parameter to allow users of the type to provide the formatting method.


Interview question 16. Which timer types does NET provide?
. NET has three built-in timer types:

 

Interview question 17 what are the similarities and differences between the three comparison methods defined in System. Object?
The static ReferenceEquals method implements reference comparison. The static Equals method allows you to call the instance Equals method more efficiently. The instance Equals method is a virtual method. The default implementation is reference comparison. You can override the instance Equals method as needed. The value type's base class ValueType overrides the Equals method to achieve content comparison.


Interview question 18 explain the principle of delegation
A Delegate is a type inherited from System. Delegate. Each Delegate object contains at least one pointer to a method, which can be an instance method or a static method. The delegate implements the callback method mechanism to help programmers design more concise and elegant object-oriented programs.
 
Interview question 19 what is the difference between the delegate callback static method and the instance method?
When the delegate is bound to a static method, the internal object member variable: _ target will be set to null. When the delegate is bound to an instance method, _ target will be set to an instance object pointing to the type of the instance method. When the delegate is executed, the instance of this object will be used to call the instance method.

Interview question 20 what is chain Delegation
A chain delegate is a linked list composed of delegates. When a delegate on a linked list is called back, subsequent delegates on all linked lists will be executed sequentially.


Interview question 21 explain the basic usage of the event
An event is a member that enables objects or classes to provide notifications. The client can add executable code for the corresponding event by providing the event handler. An event is a special delegate.


Interview question 22 explain the basic principles of reflection and the cornerstone of its implementation
Reflection is a mechanism for dynamically analyzing target objects such as assembly, module, type, and field. Its implementation relies on metadata. Metadata is a data block stored in a PE file. It records in detail the structure, reference type, and assembly list of an assembly or module.


Interview question 23 how to use reflection to implement the factory Model
The key to Using Reflection to implement a highly flexible factory model is to dynamically search for all the parts contained in the product without the need to analyze the user's needs one by one through code. The reflection factory Mode features high flexibility and low operation efficiency.


Interview question 24 how to save the Type, Field, and Method information at a low memory cost
System. runtimeTypeHandle, System. runtimeMethodHandle and System. runtimeFieldHandle contains a pointer pointing to the type, method, and field description respectively. It saves the pointer instead of saving the Information Description object of the entire type, method, and field, this can effectively reduce memory consumption. You can use these three handle types to obtain System. Type, System. Reflection. MethodInfo, and System. Reflection. FieldInfo objects.


Interview question 25 what is thread
A thread is a lightweight thread concept proposed by Microsoft. A thread has its own stack and register status. A thread can contain multiple threads. Unlike the scheduling by the operating system, the scheduling of threads in the thread is completely controlled by the programmer. The operating system kernel does not know the existence of the thread. In the. NET architecture, the thread concept does not necessarily correspond to the operating system thread. In some cases, the thread in. NET corresponds to a thread.
 
Interview question 26 how to use the. NET Thread Pool
The System. Threading. ThreaPool type encapsulates the operations of the thread pool. Every process has a thread pool, and. NET provides a thread pool management mechanism. You only need to insert the thread requirements into the thread pool, without worrying about the subsequent work. All threads in the thread pool are backend threads and they will not hinder program exit.


Question 27: what is the role of the lock keyword in C #?
In C #, the lock keyword is essentially a simplified syntax for calling the Monitor. Enter and Monitor. Exit methods. In terms of function, it achieves synchronization between the entry and Exit of an object. Generally, you can lock a private reference member variable to synchronize threads in the member method, instead, you can lock a Private Static reference member variable to synchronize threads in the static method.


Question 28: How does ASP. NET run?
ASP. NET runs as an ISAPI filter program, and is a. net clr host, thus implementing the function of running hosted server code.


Interview question 29 what is the difference between a GET request and a POST request?
There are two common HTTP requests: GET and POST. The GET request places the form data in the URI, and has restrictions on the length and data value encoding. The post request places the form data in the HTTP Request body without the length limit.


Interview question 30 introduces ASP. NET page Lifecycle
If you classify the lifecycle steps of ASP. NET pages, they can be roughly divided into four categories:

1) initialization
The initialization includes the PreInit, Init, and InitComplete steps listed above. The functions include initializing class objects, initializing the main page of the topic, and determining whether the page is accessed for the first time.
2) load data and pages
This type includes steps such as LoadSate, ProcessPostDate, PreLoad, Load, and ProcessPostData (second time. First, load the ViewState object from the data returned by the page. All data is base64-encoded and transmitted to the server along with the page. Then process the returned data, that is, store the key/value pairs in the form into the object. Then we start to load the page. Programmers usually do some initialization programming here, such as writing page initialization code in the OnLoad event. Finally, ProcessPostData is executed again to process the newly added data during Load.
Note: two processes of ProcessPostData usually confuse programmers. In fact, both processes are required. The first processing ensures that all data is read from the page before the page is loaded, so that the data can be accessed during page loading. The second ProcessPostData is used to process the data in the newly created Control During page loading. These two processes are indispensable.
3) trigger event
The trigger event contains the ChangedEvents and PostBackEvent steps. First, we will compare the data in ViewState with the data returned on the page. We think there are some events that need to be triggered. Here, the events are triggered one by one, but their order is uncertain. Then, you can check whether the Post Back event is triggered. This event is the page submitted event.
4) Save the status and display the page
The steps include SaveState, SaveStateComplete, and Render. First, the page will encode and save all ViewState data, and then embed it into a hidden control of the page. Then convert all the control labels, generate the page HTML, and send it back to the client.
Note: The above classification does not include the final Unload step, because although this step is important, it never requires the programmer's attention. ASP. NET is responsible for releasing the resources of all objects.


Interview question 31 lists several page Jump Methods
Almost every ASP. NET application requires page Jump, and there are many ways to achieve page Jump:

 

Interview question 32 How to Prevent SQL injection attacks
SQL injection attacks are often seen as an attack method that primarily utilizes the drawbacks of system design. During the design, programmers must consider injection attacks to avoid directly using user input to splice SQL statements, using encrypted data for storage, and using stored procedures in appropriate scenarios.

Interview Question 33 what types of data sources does ADO. NET Support?
ADO. NET supports four types of data sources: SQL SERVER database, ORACLE database, OLE DB provider, and ODBC provider.


Interview question 34: Briefly describe the database connection pool mechanism
ADO. NET provides the database connection pool service for upper-level users. The used database connection pool will be used for the next time. When a user applies for a database connection with a connection string, the database connection pool will try to find a connection with the same connection string in the pool and provide it directly to the user.

Interview question 35 what attributes can a connection string contain?
The connection string contains a variety of optional attributes. When performing database operations, the programmer should repeat the database connection string. Different settings will be suitable for different situations. For detailed list of connection string attributes, see table 1.

Interview Question 36What is a strong DataSet? 
Strong DataSet refers to the data types inherited from DataSet with fixed structures. Compared with DataSet, strong DataSet features convenient access and strong binding, which is conducive to the isolation of the data access layer, it is also helpful to advance the error to the compilation stage and be found.

Interview question 37What is XML 
XML is a scalable markup language. XML is a simple data storage language that uses a series of simple tags to describe data. These tags can be conveniently created, XML is extremely simple and easy to understand and use.


Interview question 38How to Use namespaces in XML 
The empty life name is used to modularize the element in the XML file. It is defined as follows:
Xmlns: namespace-prefix = "namespace ". When the parser tries to read nodes in a specified namespace, you must specify the namespace name.
 
Interview question 39How to verify the format of an XML document in. NET 
Recommended by W3C, XSD has become the most standard and common XML Schema Definition Language. In. in. NET, XmsReader supports the use of XSD files to verify whether the XML document conforms to a specific format. The programmer needs to set the XmlReaderSetting object containing the specified XSD file and traverse the XML document.

Interview question 40What is XSLT? 
XSLT is a language for format conversion of XML documents. It uses XPath to extract the required content from XML documents and organizes new formats according to specific syntax.


Interview question 41How to Use XSLT documents in code 
All types supporting XSL in. NET are defined in the System. Xml. Xsl namespace. You can use compiledtransform to convert the specified format. In addition, in the bsstructure system, the client can use javascript scripts to call the Microsoft. XMLDOM type and convert the format.


Interview question 42Briefly describe the SOAP protocol 
SOAP provides a simple and lightweight mechanism in XML form for exchanging structured and type information in a distributed or distributed environment. The SOAP Protocol defines the interaction method, but does not specify the environment and technical details of the time limit protocol. You can refer to the SOAP Protocol definition document to obtain all the Protocol content.


Interview question 43How to create a Web Service in. NET 
In. NET, you can use the built-in WebService and WebMethod features to implement Web services. This method allows programmers to focus their attention on logical work rather than dealing with communication-related work. For greater flexibility, programmers can also implement the defined asmx resource request processing type by implementing the IHTTPRequest interface. Furthermore, programmers can customize resource files and handlers to implement fully customized Web services. They only need to ensure that all the responses comply with the SOAP protocol.

 

Interview question 44How to generate a Web Service proxy type 
The Web Service proxy class refers to the proxy type responsible for SOAP communication, which allows programmers to access the Web Service server by calling the Local Web Service proxy type. In. NET, you can use the wsdl.exe tool or add Web references to generate the Web Service proxy type. The latter can easily update the proxy type after the server side changes.

Interview question 45How to Improve the Reuse Rate of connections in the connection pool 
To improve the Reuse Rate of the database connection pool, the only method is to ensure that the connection strings used by the system to access the database remain unchanged. For example, create a stepping stone database so that all connections attempt to access the stepping stone database first. In addition, the unified use of the Super User Account can further unify the connection string, but this poses a security risk to the system.


Interview question 46Which two methods does ADO. NET support to access relational databases? 
ADO. NET supports two database access methods: Connection and offline. The connector is suitable for reading large data volumes and cannot accurately predict the number of records to be read. The offline connector is more suitable for reading small data volumes.

Interview Question 47What is a relational database? 
Relational databases support relational models. In short, relational models refer to the relational table model. Compared with other models, relational databases have the advantages of easier understanding, easier use, and simpler maintenance.


Interview Questions 48What are the storage methods of sessions? What are the differences between them? How to set them? 
Session data is stored in the IIS process, status Server, SQL Server database, and custom programs. In addition to preparing necessary services (for example, SQL Server database Server), you also need to configure the website's Web. Config file.
Note: you can disable Session data in Web. Config so that Session data cannot be saved.


Interview Question 49. Briefly describe the functions and Implementation Mechanism of ViewState.
ViewState is used to store data within the page range to ensure data continuity before the user leaves the page. In implementation, ViewState is saved in a hidden control on the page and extracted and used after being submitted to the server.


Net interview FAQ

The interview usually varies from person to person

After the written test, the technical aspects will be raised from the basic questions and a little bit until you are not able to test your level.
Other problems: test your philosophy and values of human affairs and life.

Net common interview questions. Generally, the interviewer will ask what Net-related interview questions,

Generally, the interviewer seldom asks you technical questions! Just ask your work experience. Ask some projects you are working on! Wait !!

The written examination is intended for technical issues. It involves theoretical knowledge. As long as you make up the makeup, you can do it.

Related Article

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.