adspace
Answer Posted / Ankit Srivastava
Use a class when:
1. You need to create an object with state that can change during the lifetime of the object.
2. The object needs to be subclassed or inherit from other classes.
3. The object requires methods in addition to properties.nUse a struct when:
1. The value is small and frequently used as a parameter for methods without needing to change its state.
2. It's more efficient memory-wise than using a class (due to stack allocation instead of heap allocation).
| Is This Answer Correct ? | 0 Yes | 0 No |
Post New Answer View All Answers