Things you need to know about structure.
1. It is a value type and placed on a stack (class allocated on the manage heap).
structureA tempstruct=new structureA(1,2)
strucureA tempstruct2=tempstruct.
One of the example of structure is System.Drawing.Point
When to use structure instead of class.
1. Will not be changed after creation.
2. Has an instance size less than 16bytes.
3. Logically represents a single valuye.
4. Will not be cast to a reference type.
If the value of tempstruct change, it will not affect tempstruct2 because they are allocated/pointing at different piece of memory.
Advertisement