A struct is a value type and a class is a reference type.
When we instantiate a class, memory will be allocated on the heap and when struct gets initiated it gets memory on the stack.
Classes can have explicit parameter less constructors. But structs dosn't have this.
Classes support inheritance. No inheritance for structs.
A struct cannot inherit from another struct or class, and it cannot be the base of a class. Like classes, structures can implement interfaces.
Asked In: Many Interviews |