Difference between Structures and Classes:
Structures:
- Structures are value Types. Value Types are stored in stack.
- Structs are usually used for smaller amount of data.
- Structures are does not support inheritance.
- A structure couldn't have a destructor
- A structure can't be abstract
- we cannot override any methods within a structure except those belong to type of object
- Structure type where event couldn't be locked.
- The structure can't contain a volatile(Unstable) field
- We can use SIZE OF with Structures.
- Fields are cannot initialized with Structures.
- The struct can instantiated without using the new keyword.
- The struct can't have the default constructor
- The struct can't use the protected or protected internal modifier.
- The struct can't initialize at the time of declaration.
Classes:
- Classes are reference Types. Reference Types are stored in Heap.
- Classes are usually used for large amounts of data,
- Class Supports Inheritance.
- Classes have a destructor
- Classes can be abstract
- We can override any methods within a Class.
- Declared events within a class are automatically locked and then they are Thread safe
- The Classes can contain a volatile(Unstable) field
- We cannot use SIZE OF with Structures.
- Fields are automatically initialized with classes
- The new keyword should be used to create the object for the class
- The class will have the default constructor
- The class can use all the access modifiers.
- The class can have the initializes fields.
No comments :
Post a Comment