) Interview Questions

Source: Internet
Author: User

>What is. Net? What isCLI? What isCLR?IlWhat is it?JITWhat does it work?GCWhat is it, brieflyGCMethod of work?

CLI is a standard; CLR is the implementation of CLI;. Net is a framework built based on CLR;

Developers need to communicate with CLR through Il. Although IL itself supports some object-oriented concepts, it is too complicated and inefficient for developers, So C # came into being,ProgramDevelopers only need to write C #Code, CSC compiler will translate it into il;

Although CLR understands Il, CPU only knows binary commands. Therefore, CLR needs JIT help to translate il into CPU commands. JIT works as needed when. when the net method is about to be executed, JIT will intervene to compile the method (IL command) into a CPU command and save it for reuse.

GC is used to recycle unattended junk objects in the current process. GC is triggered by some events (for example, the 0-generation object is full, the memory pressure is high, and the appdomain is uninstalled ), then, the system traverses the objects on the GC stack and uses "whether the object is directly or indirectly referenced by root" (further, "whether an object can be recycled" depends on F-reachable queue and GC handle table) to determine whether an object needs to be recycled.

>Class (Class) And structure (Struct) What is the difference? Do they affect performance?. Net BclWhich of the following are classes (structures) and why are they not structures (classes )? How do you select a class or structure when customizing the type??

In short, the class is a reference type, and the structure is a value type;

Value Type objects are directly allocated to the stack of the current thread, and reference type objects are on the GC stack. Therefore, value type objects cannot be passed in multiple methods, the reference type will undertake more tasks, for example, for thread synchronization (Monitor. enter (...)) When an object of the reference type is created, 4 + 4 = 8 bytes of extra space (32bit OS) will be required ), at the same time, excessive use of reference type objects will increase the pressure on the GC heap. Frequent GC may affect the program performance.

The byte type in BCl is a struct. As to why it is not a class, I think it may be because the designer thinks that the byte should not be inherited, or the extra costs of 8 bytes cannot be borne.

When to use the value type/reference type or the specific situation should be analyzed. For the reference type, sealed can be used for sealed, and the overhead will be smaller during method calling.

>In. NetWhat is a heap and a stack when the program is running? Under what circumstances will data be allocated on the heap (stack? Are there any performance differences between them?"Structure"Can objects be allocated to the stack? Under what circumstances will happen and what should I pay attention??

. When a net process is created, a heap is created to save the objects/data that the process needs to use during running. When a thread is created, a stack is created, used to save lightweight data such as method call parameters and local variables.

When a class contains a variable of the struct type, the struct type will be allocated to the stack. (I do not know what to note ...)

> What is the role of generics? What are its advantages? Does it affect performance? What is its behavior during execution?. Net BclWhich generic types are available? Examples of generic types that you define in normal programming

Wildcard is beneficialAlgorithmReuse.

. In the net process address space, objects and types are stored separately. When we instantiate a generic type (such as list <int> List = new list <int> ();), A New Type object will be created (this object is not on the GC stack). When we use this instantiated generic type to create a new object, there will be an object (on the GC stack) created. so there will be some performance loss. when we use a value type as a parameter to call a method to receive parameters of the reference type, there will be a boxing case. In this case, we can consider implementing a generic type, determine the parameter type of the method at runtime.

>What is the role of an exception?. Net BclWhat are common exceptions? How do you capture/Handling abnormal? In theCatch (Ex )"Medium,"Throw"And"Throw ex"What is the difference? How do you design an exception structure, and under what circumstances do you throw an exception??

Er, an exception can notify us of program errors, such as argumentexception, nullreferenceexception...

An exception may cause a stack walk to look for the corresponding exception handler. In this process, the stack trace information is collected layer by layer, throw ex clears the collected stack trace information, which is equivalent to throwing a new exception, but throw does not, so throw ex is not conducive to identifying the problem.

Different layers should catch different exceptions. The top layer should handle the most general exceptions, and the bottom layer should handle some detail exceptions.

> List <t>AndT []What is the difference? How do you choose?Dictionary <tkey, tvalue>What is it?. Net BclWhich of the following commonly used containers are available? How are they implemented (which data structure )? Which scenarios are applicable??

T [] inherits from the array, while list <t> is only an encapsulation of T []. Compared with T [], the size of list <t> is dynamically changed.

Dictionary <tkey, tvalue> can be used to store key/value pairs. Other types include hashtable and sortedlist.

>What is the difference between an abstract class and an interface? What do you need to pay attention to when using it? How to choose is to define"Full Abstraction"Is it an abstract class or an interface? What is an interface?"Explicit implementation"? Why is it important??

An abstract class defines a class and its subclass, and more interfaces show what a class can do.

When a class is connected to a different interface, and these two interfaces contain methods with the same signature, the display implementation is required.

>Is the string of the reference type or structure type? Is it more special than a common reference type? What should I pay attention to when using strings? Why?StringbuilderRelatively efficient? When connecting multiple strings, is it more efficient than directly adding strings at any time??

String is a reference type. Its special feature is that a string is unchangeable. When we connect two strings, A New String object is generated, the original two strings remain unchanged.

When InterOP is performed with native code, for outgoing parameters (char * outstr), use stringbuilder instead of string.

Stringbuilder maintains an internal char [] array, which dynamically increases the size of the connected characters. However, when the original array is insufficient, stringbuilder will re-create a new char [] array. It is worth noting that the original array will not be discarded, and the newly created array will only be used to store new characters.

If stringbuilder has "no efficiency", it should be in the case that the original array space is exhausted.

>How to efficiently copy arrays?"Two-dimensional array"And"Array"What is the difference? How to select the traversal sequence of the internal and external layers when traversing a two-dimensional array using a double loop?

I don't know, because the distribution of array elements in the memory is continuous, the method I can think of is to directly use the memory copy API.

The two-dimensional array is two-dimensional, and the array is one-dimensional.

According to the principle of memory locality, the first element that the CPU reads from a two-dimensional array is that the data in the first row is also read into the cache. Therefore, we should traverse the rows and then traverse the columns.

>What is. Net? What isCLI? What isCLR?IlWhat is it?JITWhat does it work?GCWhat is it, brieflyGCMethod of work?

CLI is a standard; CLR is the implementation of CLI;. Net is a framework built based on CLR;

Developers need to communicate with CLR through Il. Although IL itself supports some object-oriented concepts, it is too complicated and inefficient for developers, So C # came into being, programmers only need to write C # code, and the CSC compiler will translate it into il;

Although CLR understands Il, CPU only knows binary commands. Therefore, CLR needs JIT help to translate il into CPU commands. JIT works as needed when. when the net method is about to be executed, JIT will intervene to compile the method (IL command) into a CPU command and save it for reuse.

GC is used to recycle unattended junk objects in the current process. GC is triggered by some events (for example, the 0-generation object is full, the memory pressure is high, and the appdomain is uninstalled ), then, the system traverses the objects on the GC stack and uses "whether the object is directly or indirectly referenced by root" (further, "whether an object can be recycled" depends on F-reachable queue and GC handle table) to determine whether an object needs to be recycled. the details are not exactly half an hour.

>Class (Class) And structure (Struct) What is the difference? Do they affect performance?. Net BclWhich of the following are classes (structures) and why are they not structures (classes )? How do you select a class or structure when customizing the type??

In short, the class is a reference type, and the structure is a value type;

Value Type objects are directly allocated to the stack of the current thread, and reference type objects are on the GC stack. Therefore, value type objects cannot be passed in multiple methods, the reference type will undertake more tasks, for example, for thread synchronization (Monitor. enter (...)) When an object of the reference type is created, 4 + 4 = 8 bytes of extra space (32bit OS) will be required ), at the same time, excessive use of reference type objects will increase the pressure on the GC heap. Frequent GC may affect the program performance.

The byte type in BCl is a struct. As to why it is not a class, I think it may be because the designer thinks that the byte should not be inherited, or the extra costs of 8 bytes cannot be borne.

When to use the value type/reference type, or should it be analyzed based on specific conditions? I prefer to use the reference type because it will be less costly during design, but sealed can be used for sealed, the overhead for method calling is smaller.

>In. NetWhat is a heap and a stack when the program is running? Under what circumstances will data be allocated on the heap (stack? Are there any performance differences between them? Can "structure" objects be allocated to the stack? Under what circumstances will happen? Do you need to pay attention to it??

. When a net process is created, a heap is created to save the objects/data that the process needs to use during running. When a thread is created, a stack is created, used to save lightweight data such as method call parameters and local variables.

When a class contains a variable of the struct type, the struct type will be allocated to the stack. (I do not know what to note ...)

>What is the role of generics? What are its advantages? Does it affect performance? What is its behavior during execution?. Net BclWhich generic types are available? Examples of generic types that you define in normal programming.

Generics facilitate algorithm reuse.

. In the net process address space, objects and types are stored separately. When we instantiate a generic type (such as list <int> List = new list <int> ();), A New Type object will be created (this object is not on the GC stack). When we use this instantiated generic type to create a new object, there will be an object (on the GC stack) created. so there will be some performance loss. when we use a value type as a parameter to call a method to receive parameters of the reference type, there will be a boxing case. In this case, we can consider implementing a generic type, determine the parameter type of the method at runtime.

>What is the role of an exception?. Net BclWhat are common exceptions? How do you capture/Handling abnormal? In"Catch (Ex )"Medium,"Throw"And"Throw ex"What is the difference? How do you design an exception structure, and under what circumstances do you throw an exception??

Er, an exception can notify us of program errors, such as argumentexception, nullreferenceexception...

An exception may cause a stack walk to look for the corresponding exception handler. In this process, the stack trace information is collected layer by layer, throw ex clears the collected stack trace information, which is equivalent to throwing a new exception, but throw does not, so throw ex is not conducive to identifying the problem.

Different layers should catch different exceptions. The top layer should handle the most general exceptions, and the bottom layer should handle some detail exceptions.

> List <t>AndT []What is the difference? How do you choose?Dictionary <tkey, tvalue>What is it?. Net BclWhich of the following commonly used containers are available? How are they implemented (which data structure )? Which scenarios are applicable??

T [] inherits from the array, while list <t> is only an encapsulation of T []. Compared with T [], the size of list <t> is dynamically changed.

Dictionary <tkey, tvalue> can be used to store key/value pairs. Other types include hashtable and sortedlist.

>What is the difference between an abstract class and an interface? What do you need to pay attention to when using it? How to choose is to define"Full Abstraction"Is it an abstract class or an interface? What is an interface?"Explicit implementation"? Why is it important??

An abstract class defines a class and its subclass, and more interfaces show what a class can do.

When a class is connected to a different interface, and these two interfaces contain methods with the same signature, the display implementation is required.

>Is the string of the reference type or structure type? Is it more special than a common reference type? What should I pay attention to when using strings? Why?StringbuilderRelatively efficient? When connecting multiple strings, is it more efficient than directly adding strings at any time??

String is a reference type. Its special feature is that a string is unchangeable. When we connect two strings, A New String object is generated, the original two strings remain unchanged.

When InterOP is performed with native code, for outgoing parameters (char * outstr), use stringbuilder instead of string.

Stringbuilder maintains an internal char [] array, which dynamically increases the size of the connected characters. However, when the original array is insufficient, stringbuilder will re-create a new char [] array. It is worth noting that the original array will not be discarded, and the newly created array will only be used to store new characters.

If stringbuilder has "no efficiency", it should be in the case that the original array space is exhausted.

>How to efficiently copy arrays?"Two-dimensional array"And"Array"What is the difference? How to select the traversal sequence of the internal and external layers when traversing a two-dimensional array using a double loop?

I don't know, because the distribution of array elements in the memory is continuous, the method I can think of is to directly use the memory copy API.

The two-dimensional array is two-dimensional, and the array is one-dimensional.

According to the principle of memory locality, the first element that the CPU reads from a two-dimensional array is that the data in the first row is also read into the cache. Therefore, we should traverse the rows and then traverse the columns.

>What is metaprogramming,. NetWhat meta-programming methods and scenarios are there? What is reflection? Can I introduce some common reflection scenarios? Some people say that the reflection performance is poor. What do you think of this problem? Is there any way to improve the reflection performance?

I have little knowledge about metaprogramming.. Net codedom (or dynamic creation of Types Using Reflection emit) should be one of the scenarios.

Based on metadata, reflection helps us dynamically obtain information about the assembly, type, method, and attribute at runtime, and can be used to load addin.

If there is a loss, the reflection function is powerful. As long as it is not abused, the benefits will be far greater than the performance loss.

>What is delegation? What is an anonymous method? InC #3.0Medium,LambdaWhat is an expression? What is the extension method?LINQWhat is it? You thinkC #3.0What are the important features they bring about?BclWhich class libraries are related to these features? Which of the following are your most commonly used

The delegate can be considered a type-safe function pointer. 741 words are omitted here...

>What technical books, websites,Community, Project, etc? What else do you have access?. NetOther technologies. NetOr. NetAre there targeted parts for comparison?

Onecode is a good project

 

Http://blog.csdn.net/Sento/archive/2011/03/06/6226381.aspx

Source of http://blog.zhaojie.me/2011/03/my-interview-questions-for-dotnet-programmers.html

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.