Difference between struct and class in C#
?
1. Definition:
?
2. Memory Allocation:
?
3. Default Behaviour:
?
4. Inheritance:
??? Structs do not support inheritance, while classes support single inheritance.
?
5. Nullability:
?
6. Performance:
?
7. Usage:
?
8. Example:
???// Struct example
public struct Point
{
public int X;
public int Y;
}
// Class example
public class Person
{
public string Name;
public int Age;
}
A seeker of great opportunities ?
4 个月Nice explanation sir ??