1) What happens when you build the
application in .Net? Or Explain the Compilation process in .Net ?
1. When you build the application, .NET Runtime will select the proper compiler (Eg: C# or VB Compiler), and Converts the code to MSIL Code.
3. Finally it executes the processor specific code.
2) GC Functionality and Generations in GC ?
Garbage Collector (GC) freezes the memory of the objects automatically. Developer doesnt need to freeze the memory of the object explicity.
There are 3 generations in GC viz.,
- 0,1 and 2. When an object is first created, it goes into the Zeroth (0th ) generation.
- When oth generation is filled the GC is invoked. GC Checks and freezes the memory of the objects for which there is no reference. If the reference for the object is available that object will be moved to Generation 1.
- When Generation 1 is filled, again GC Will be invoked, If the reference for any object is available in Generation 1, that object will be moved to Generation 2.
- When the final (Generation 2 ) is filled, GC will be invoked and freezes the memory of those objects for which there is no reference. The objects which is having reference will be available in Generation 2 itself.
A class can be declared static, indicating that it contains only static members. It is not possible to create instances of a static class using the new keyword. Static classes are loaded automatically by the .NET Framework common language runtime (CLR) when the program or namespace containing the class is loaded.
The main features of a static class are:
- They only contain static members.
- They cannot be instantiated.
- They are sealed.
• A static variable will be shared across all instances of the aspx page, meaning that it is the same variable for every request that is coming in. We can modify the value in the static var.
When to use Static Class :
So, when you design a class, ask yourself
Does this method belong to an object,or the class itself ?
- A method belongs to an object, if it modifies the state of the object. State of the object means modifying datatable or dataset object or any object in a particular method then you cannot make that method as static.
- If the method does not modify a specific object, it can most likely be static. Methods in the Data access layers can be static because you wont be modifying any state of the object in that. Eg: GetEmployeeDetails(int EmployeeID) which gets the employee details from the Database.
- The Managed Extensibility Framework (MEF) is a composition layer for .NET that improves the flexibility, maintainability and testability of large applications.
- The basics of MEF can be summarized in 3 simple words: Export, Import, and Compose.
No comments:
Post a Comment