Take the test recently. Sort out. net knowledge. This is written based on memory. It may be inaccurate. Please point it out when you see the error. I will maintain it all the time and try to maintain it correctly.
. Net framework mechanism
. Net framework includes. net CLR, CTS, CLS, CLI, and BCL.
CLR-Common Language Runtime is the environment in which. net programs run. CLR includes the execution engine, Automated memory management (GC and how it works ),. net assembly (a special Portable Executable) definition, class loader (strictly speaking, class loader is part of the execution engine), IL to the binary compiler, etc.
CTS-Common Type system is a standard Type system that is used by different advanced languages on the. net platform. It is compatible at the IL level.
CLS-Common Language Specification has many elements in IL. all the advanced languages on the net platform have the features of interoperability and preparation. For example, VB.net does not support case sensitivity, so CLS has the case-insensitive feature. All of these features are designed to ensure interoperability between high-level languages. C # most languages Support CLS.
CLI-Common Language infrastructure is a subset of CLR. Including class loader, IL to binary compiler, GC, etc.
AppDomain-A memory area managed by CLR, including the image, stack, and heap of the Assembly in the memory. A process can have multiple AppDomains, and the same thread can access multiple AppDomains. At CLR4.0 or later, multiple AppDomains of a process can correspond to different CLR versions.
Assembly-is the executable file .exe or dll of the compiled .net. It includes various types of metadata and the IL code of the method body.
Class library of the BCL-Business class library. net framework. These class libraries implement some functions. For example, database access.
Shared Assembly-for example, mscorlib. dll, which is an Assembly that must be referenced by each. net Assembly, contains the most basic things in the System namespace. Shared Assembly is Shared across multiple AppDomains. Such as mscorlib. dll can also be shared across processes. It is mapped to the VAS (virtual address space) of different processes.
Dedicated Assembly-We usually write our own Assembly, which is Dedicated. Exists in a specific AppDomain.
. Net Framework Version and compatibility
Official: http://msdn.microsoft.com/en-us/library/bb822049.aspx
. Net Memory Management
There is a lot of content, so I just want to write a little bit.
The value type is allocated in the stack, and the reference type is allocated in the heap. If a value type is a member of the reference type, memory is allocated in the heap along with the reference type.
Packing-to put a value type into the heap, You need to convert it into a reference type Object before putting it into the heap.
Unboxing-extract a boxed value type from the heap, convert it to a value type, and then assign it to the variable.
When collecting the root-GC, you can determine whether a variable can be collected, that is, whether the reference pointing to this variable can be found from the root. Both direct and indirect references are acceptable. If yes, it is still in use. If you cannot find any reference from the root to this variable, you can collect the space of this variable. Root refers to static variables, local variables, CPU registers, etc.
Collection-use the above method to find the root to determine whether some variables are still in use. Find unnecessary variables, and you can mark them for collection. At the end of a collection, the memory needs to be compressed, and the scattered spaces are compressed. In addition, the variables that exist after a collection will be moved to the memory space of another generation.
Generation and generation space-. net CLR creates three generations of memory space when a process starts, namely, 0, 1, and 2. These are pre-designed default values to set the size of each generation of space. New Variables always allocate space in the zero-generation space. After a collection algorithm is completed, the existing variables are moved from the space of generation 0 to the space of Generation 1. If garbage collection occurs in the space of Generation 1, the existing variables will be moved to the space of generation 2. Garbage collection is divided into generation 0, Generation 1 and generation 2. If generation 2 is collected, Generation 1 and generation 0 must be followed, and the order is generation 0, Generation 1, and generation 2. If generation 1 is collected, generation 0 also needs to be collected. The order is generation 0, Generation 1.
Large Object heap-. net has a large object heap. It is used to allocate and collect large objects. The large object heap does not fragment. The cost of moving large objects is relatively high, so fragments are not arranged.
Finalize method-a solution used when the programmer forgets to release the object. When an object with the Finalize method is created, a link is added to the CLR end queue. Once this object is no longer used and Dispose () is not explicitly called, GC moves the reference of this object in the end queue to the end queue, then there is a separate thread to run the Finalize method of objects in the queue to be terminated one by one to release resources. See: http://www.cnblogs.com/mikelij/archive/2009/05/15/1779850.html
Test stand-alone tool VisualStudio
MSTest/testcontainer: testproject1.dll to run all the tests in this test project dll.
/Test: <testname> run the specified test.
Load testing tool VisualStudio
Create a Web test, specify the host, and parameterize it. Then create a Load test to associate Web test with Load test.
NUnit
Write the Testfix method and the TearDown method, and then run the [Test] method with NUnit. the Test method returns the correct result, which is green.
SpecFlowhttp: // response? Loc = tashangchuan can either use MSTEST or NUnit. C #2.0 Delegate and Event differences
Delegate and Event are a complete set and a subset. Events can also be used with Delegate. Delegate is the implementation of the Observer mode (also called model-view, publisher-subscriber, source-lister mode) in C.
However, Event provides better encapsulation and ease of use. The delegate variable of the Event type can only use the + =,-= operation outside. in the outside world, you cannot perform the value assignment (=) operation or directly call mydelegate ().
However, delegate can be directly called and assigned values.
Implement delegate
It is very easy to implement a delegate. You can use the following three steps to implement a delegate:
1. Declare a delegate object. It should have the same parameter and return value type as the method you want to pass.
2. Create a delegate object and pass in the functions you want to pass as parameters.
3. Use the object created in the previous step to call the method where an asynchronous call is to be implemented.
Event implementation steps:
With the implementation of delegate, We can summarize the implementation of custom events into the following steps:
1. Define the delegate object type. It has two parameters. The first parameter is the event sender object, and the second parameter is the event parameter class object.
2. Define the event parameter class, which should be derived from the system. eventargs class. This step can be omitted if the event does not contain parameters.
3. Define the event processing method. It should have the same parameter and return value type as the delegate object.
4. Use the event keyword to define the event object, which is also a delegate object.
5. Add the event to the event queue with the + = Operator (the-= operator can delete the event from the queue ).
6. Call the delegate method to write the event trigger method where an event needs to be triggered. In general, this method should be a protected access restriction. It cannot be called in public mode, but can be inherited by the quilt class. The name is on.Eventname.
7. Call the event trigger method to trigger the event where appropriate.
Exception handle best practice:
Http://msdn.microsoft.com/en-us/library/seyhszts (v = vs.110). aspx