Friday, July 3, 2009

Value type can have an implict Constructor?

All the value type is initialized to zero or null.This is because it dont have a implict constructor.

ways you can define a variable

1) variable inside a Reference Type
ie
E.g:
Class c
{
int i;
};

test()
{
c C = new c(); //At this point GC will take care of it
}

Note : GC checks the variable is zero or NULL before releasing the variable from heap.

2) Inside Value type

struct structDemo
{
int i;
};
test()
{
c C = new c(); //At this point JIT will take care of it
}

Note : JIT checks inside the stack.if nothing is defined stack place occupied with zero labeled.
3)If value type has a value ,stack occupied with the that value as labled


0 comments:

 
Counter