i) A structure is a value type, while a class is a reference type.
ii) When we instantiate a class, memory will be allocated on the heap. When structure gets initiated, it gets memory on the stack.
iii) Classes can have explicit parameter less constructors. But structs cannot have this.
iv) Classes support inheritance. But there is no inheritance for structs.
v) We can assign null variable to class. But we cannot assign null to a struct .
vi) We can declare a destructor in class but can not in struct.
No comments:
Post a Comment