Class
A user-defined data
structure that groups properties and methods. Class doesn’t occupies memory.
ObjectInstance of Class is called object. An object is created in memory using keyword “new”.
Difference between Struct and Class
·
<!--[if
!supportLists]--> Struct are Value type and are stored on stack, while Class
are Reference type and are stored on heap.<!--[endif]-->
·
<!--[if
!supportLists]--> Struct “do not support” inheritance, while class supports
inheritance. However struct can implements interface.<!--[endif]-->
·
<!--[if
!supportLists]--> Struct should be used when you want to use a small data
structure, while Class is better choice for complex data structure.
No comments:
Post a Comment