Monday 29 October 2012

What is Difference between Class and Structure in C#.


Class:
1.)Class is reference type . Instance of a class are stored on the heap.
2.)It  support all the OOP’S concept.
3.)It has an explicit default constructor.
4.) Field is initialized when they are declared in the class.

Structure:
1.) Structure is value type. Instance of structure are stored on stack area.
2.)It doesn’t support inheritance.
3.)It cannot have explicit default constructor.
4.) Fields cannot be initialized when they are declared in the structure.

No comments:

Post a Comment

Note: only a member of this blog may post a comment.