Classes are reference types, whereas structs are value types.
Class
- Heap Memory
- Supports Inheritance
Struct
- Stack Memory
- No Inheritance
Example
class Employee
{
}
struct Student
{
}
Interview Tips
Structs are lightweight.
Classes are reference types, whereas structs are value types.
class Employee
{
}
struct Student
{
}
Structs are lightweight.