Thursday, May 29, 2008

Structures in C#

Structures:

 

Points:

1. Its a value type so if we assign a value to another struct then it is stored at two different point in the stack.

2. We cannot have a explicit empty constructor in a structure.

3. Structure cannot have constructors that do not completely initialize all the variables in it.

4. There is a 16 byte size limit to structure's instance. All value types are 16 bytes or shorter.

5. It is logically a single value.

6. It will not be cast to a reference type.

7. If a copy of a structure is passed to another procedure or function then the original will not change after the call. This is because a copy is passed to that procedure or function.

8. Value types are far more efficient then reference types however there is a instance size limit.

No comments: