Class Vs Structure in c#?

Following are the key differences between them: -
1. Structures are value types and classes are reference types. So structures use stack and classes use heap.
2. Structures members can not be declared as protected, but class members can be. You can not do inheritance in structures.
3. Structures do not require constructors while classes require.
4. Objects created from classes are terminated using Garbage collector. Structures are not destroyed using GC.

Need Help? Contact Us.

Log in

*
*

Forgot password?

*

New User

*
*
*
*