Friday, February 18, 2011

.NET FRAMEWORK & CORE CONCEPT

Like any other plateform, the .Net Framework introduces terimnology that you need to be aware of Following is a list of some of these terms:

1. CLR
The Common Language Runtime (CLR) is a key .Net Framework component. The CLR is the container, or the execution environment, in which all the managed code runs. The CLR getsits name from the fact that .Net provides a binary standard and any programming language that adheres to the binary standard can be used for writing code that can be run by the CLR. In its infrastructure services to support execution of managed code. These services include automatic memory management, type safety, thread and process management, security and versioning. The CLR sits between the managed code and the operating system so that your code is insulated from interacting directly with the operating system. This arrangement makes your code portable to some extent and also frees you from having to do system-level tasks so that you can concentrate on writing application code.

The CLR provides the following services:
  • Code Management
  • Software memory isolation
  • Verification of the tyoe safety of MSIL
  • Conversion of MSIL to native code
  • Loading and execution of managed code (MSIL or native)
  • Accessing metadata (enhanced type information)
  • Managing memory for managed objects
  • Insertion and execution of securty checks
  • Handling exceptions, including cross-language exceptions
  • Interopeation between .NET Framework objects and COM objects
  • Automation of objects layout for late binding
  • Supporting developer services (Profiling, debugging, etc.)
2. MANAGED CODE
The Code which is managed by CLR.
Managed code runs under a contract of cooperation with the CLR. This means that managed code must supply the metadata necessary for the runtime to provide services such as memory management, cross-language integration, code access security, and automatic control of objects lifetime.

3. MSIL
The Microsoft intermediate Language (MSIL) is the equivelent of Java byte code. The MSIL executes the managed code. languages that support generating MSIL can leverage the infrastructure services of the CLR.
MSIL is a stack based set of instructions designed to be easily generated from source code by compilers and other tools. Several kinds of instructions are provided, including instructions for arithmetic and logical operations, control flow, direct memory access, exception handling,and method invocation. These is also a set of MSIL instructions for implementing object-oriented programming constructs such a s virtual method caals, field acess array access, and object allocation and initialization.


4. JIT
The CLR provides three JIT compilers for converting MSIL to native code: EconoJIT,JIT, and OpJIT. Each JIT compilers has been designed to meet specific gaols with respect to performance and resource usage. The performance charactristics are summarized:
JIT Compiler Input Language JIT Compiler Overhead Compilation Speed Quality of Output
EconoJIT MSIL(incl. OptIL) Very Small Very Fast Low
JIT MSIL(incl. OptIL) Medium to large Moderate High
OptJIT OptIL only Small Fast High
Because of the low overhead of the EconoJIT compiler, as well as the ease with which it can be ported to new architectures, the .NET Framework does not include an interpreter for MSIL. (EconoJIT is so named becauseit performs the same task as the full JIT compiler but using less computer resources. As a trade-off, the quality of the generated code is not so high).


C# Interview Question and Answers



C# Tools :

C#.Net Interview Questions ans Answers

Q1. What’s the advantage of using System.Text.StringBuilder over System.String? 
Ans.  StringBuilder is more efficient in the cases, where a lot of manipulation is done to the text. Strings are immutable, so each time it’s being operated on, a new instance is created.

Q2.What’s a satellite assembly? 
Ans. When you write a multilingual or multi-cultural application in .NET, and want to distribute the core application separately from the localized modules, the localized assemblies that modify the core application are called satellite assemblies.

 Q3. Is it possible to inline assembly or IL in C# code?
Ans.  No
 
Q4. Is it possible to have a static indexer in C#?
Ans. No, Static indexers are not allowed in C#.

Q5. Does C# support multiple-inheritance?
Ans. No.

Q6. Who is a protected class-level variable available to?
Ans. It is available to any sub-class (a class inheriting this class).

 Q7. How can you sort the elements of the array in descending order?
Ans. By calling Sort() and then Reverse() methods.

Q8. Explain the three services model commonly know as a three-tier application.
Ans. Presentation (UI), Business (logic and underlying code) and Data (from storage or other sources).

Q9. Can multiple catch blocks be executed for a single try statement?
Ans. No. Once the proper catch block processed, control is transferred to the finally block (if there are any).

Q10. Will the finally block get executed if an exception has not occurred?
Ans. Yes.

Q11. Is it possible to have different access modifiers on the get/set methods of a property?
Ans. No. The access modifier on a property applies to both its get and set accessors. What you need to do if you want them to be different is make the property read-only (by only providing a get accessor) and create a private/internal set method that is separate from the property. 

Q12. Can multiple catch blocks be executed?
Ans. No, once the proper catch code fires off, the control is transferred to the finally block (if there are any), and then whatever follows the finally block.

 Q13. What are the ways to deploy an assembly?
Ans. An MSI installer, a CAB archive, and XCOPY command.

Q14. What is the name of c#.net compiler?
Ans. CSC

Q15. what is the main difference between delegate and an event in c#?
Ans. Delegates and Events Both are related. Dalegete is a function pointer which can able to store the address of any function with same prototype.Event is a function handler which can handles or run the functions in same prototype of its delegate.For handling the events delegate is uesd.