Reference Types (String + Object): String and Objects are reference Types.
When we create an Object of a class it gets stored on Heap and a pointer/reference is set on STACK which points to object.
E.g. Class A =new Class ();
In above example Object A is created in 2 steps
1. Class A; //Reference of Object A. At this time its value is set to null
2. A=new Class (); //Now Object A is created and at the same time reference A is pointing to created Object A.
From the above example we can say when we create an object of a class then the created object get stored on HEAP and at the same time reference of that object get stored on STACK.
Value Types: All types are value types except String and Objects.
Please follow below link for detail:
http://www.codeproject.com/Articles/76153/Six-important-NET-concepts-Stack-heap-value-types
When we create an Object of a class it gets stored on Heap and a pointer/reference is set on STACK which points to object.
E.g. Class A =new Class ();
In above example Object A is created in 2 steps
1. Class A; //Reference of Object A. At this time its value is set to null
2. A=new Class (); //Now Object A is created and at the same time reference A is pointing to created Object A.
From the above example we can say when we create an object of a class then the created object get stored on HEAP and at the same time reference of that object get stored on STACK.
Value Types: All types are value types except String and Objects.
Please follow below link for detail:
http://www.codeproject.com/Articles/76153/Six-important-NET-concepts-Stack-heap-value-types
No comments:
Post a Comment