In c# provides a unique way of packing together different
data types called as struct.
Struct is a simple lightweight alternative to class,but
struct are basically same as class even though they have some significant
difference between struct and class.
Classes
|
Structs
|
Classes are declared using Class
keyword
|
Struct are declared using Struct
keyword
|
Its a refrence type therefore its stored on the heap
|
It’s a value type and
therefore stored on the stack
|
Support inheritance
|
Does not support inheritance
|
Default value of the class type is null
|
Default value is the value produced by ‘zeroing out’
|
Permit initialization of instance fields
|
Do not Permit initialization of instance fields
|
Permit declaration of parameterless constructors
|
Do not Permit declaration of parameterless constructors
|
Destructors is supported
|
Destructors is not
supported
|
Assignment copies the reference
|
Assignment copies the vaues
|
0 comments:
Post a Comment