+ 2
Struct vs Class in C#
This is not a question, it is just to clarify the difference between struct and class
1 Respuesta
+ 9
the basic difference is in the instantiation..a struct by default is not initialized using the new keyword bt a class is.
this means that struct doesn't have a default constructor just like classes (unless otherwise created).
Also struct is a value type while class is a reference type. This means that struct variables directly hold the values themself but class variables are more like reference to the value, they hold they address to the value.
value type variables are stored on the stack memory where they directly hold the values while reference type variables store the values on the heap memory and then the reference to this value is then stored on the stack memory.