For training related to .net,OOPS,design patterns, MVC,WCF and .net fundamentals
contact at sukeshmarla@gmail.com or Click Here

23 April 2011

Class Vs structures


1. Classes are reference types and structs are value types.
    means Class will be allocated on a heap and structs will be allocated on the stack.

2. You cannot have instance Field initializers in structs.
    means we cant have variables as structs instance members.
3. Classes can have explicit parameter less constructors. But struts cannot have.
4. Classes must be instantiated using the new operator. But struts can be without.
5. Class support Polymorphism and inheritance but struct wont.
6. Protected and ProtectedInternal is not supported in struct.
8. A class is permitted to declare a destructor. But a struct is not
7. classes are used for complex and large set data. structs are for simple data structures.