Thursday, November 24, 2011

Role of Common Language Run-Time(CLR) in .net framework

The CLR is very important part of .net framework. It is execution engine for .net framework application. It also provides important capabilities in optimizing, securing and providing many robust capabilities such as application deployment and side by side execution.
 CLR provides no. of services that includes-
  • Code management(loading and execution)
  • application memory isolation
  • veryfication of type safety
  • conversion of IL to Native
  • Access to metadata(enhance type information)
  • Managing memory for managed objects
  • Enforcement of code access security
  • Exception handling, including cross-language exception
  • Interoperation between managed code, COM objects, and pre-existing DLL(Unmanaged code and Data)
  • Automation of object layout
  • Support for developer service(profiling, debugging and so on)

Tuesday, August 16, 2011

Unboxing

Unboxing is an explicit conversion from the object to value type or from an interface type to a value type that implements the interface.
     An unboxing operation consists of:
* Checking the object instance to make sure it is a boxed value of the given value type.
* coping the value from the instance into the value type variable. 

Tuesday, July 5, 2011

Boxing

Boxing is an implicit conversion of a value type to a reference type. Consider the following value type variable.
           int a=12;
now boxing operation on above variable,
         object o=i; //boxing
Above statement create an object, on the stack, that references a value of type int, on the heap. this value is a copy of the vaue-type value assigned to the variable a. we ca understand it by following fig.


It also possible, but never needed to perform the boxing explicitly as in the following example:
           int a=12;
           object o= (object)  i;
  

.Net Plateform

The .Net Plateform is a set of technologies. The Microsoft .Net Plateform consists of the following core technologies:

 
  • The .net framework
  • The .net enterprise server
  • Building block services
  • Visual studio .net

Monday, July 4, 2011

Dereference Operator(*)

We know that pointer is a variable that holds memory address of another variable. We can directly access the value of a variable using a pointer pointing to address of that variable. For this we will use the indirection operator (*) also known as dereference operator(*).  By placing the dereference operator before a pointer variable, we can access the variable whose address is stored in the pointer. Let us an Example:
                int a=65;
                int *p=&a;
Now, in our program, if we place '*' before p then we can access the variable whose address is stored in p. Since p contains address of  variable a, we can access variable a by writing *p. So we can use *p in place of varible name a. For Example.
*p=2 is equivalent to a=2..
(*p)++ is equivalent to a++.
The dereference operator can be read as "value pointed by" or "value at the address". For example * p can be read as "value at the address p" or " value pointed by p".