Points
Struct is a value type that can contain data and functions.
Struct is a value type, so no heap is required. Instead, space is allocated on the stack.
Struct directly stores data in struct, while class only stores pointer of reference type
Struct applies to small data structures
Struct affects performance
Struct can use the new operation to call the constructor, but does not allocate memory on heap.
The struct constructor returns only the struct value itself (usually allocated on the stack)
When using class, multiple variables can reference the same object.
Each sturct variable is used to save its own data copies without affecting each other.
Struct does not support inheritance. sturct inherits from object type.
Demo
class Program { class PointClass { public int x; public int y; public PointClass(int x, int y) { this.x = x; this.y = y; } } struct PointStruct { public int x; public int y; public PointStruct(int x, int y) { this.x = x; this.y = y; } } static void Main(string[] args) { PointStruct pointStruct = new PointStruct(10, 10); Console.WriteLine("Initial struct values are {0},{1}", pointStruct.x, pointStruct.y); ModifyStructPoint(pointStruct); Console.WriteLine("After ModifyStructPoint, struct values are {0},{1}", pointStruct.x, pointStruct.y); Console.WriteLine(); PointClass pointClass = new PointClass(10, 10); Console.WriteLine("Initial Class values are {0},{1}", pointClass.x, pointClass.y); ModifyClassPoint(pointClass); Console.WriteLine("After ModifyClassPoint, class values are {0},{1}", pointClass.x, pointClass.y); Console.ReadLine(); } private static void ModifyStructPoint(PointStruct pointStruct) { pointStruct.x = 20; pointStruct.y = 20; Console.WriteLine("Modified Valuesare {0},{1}", pointStruct.x, pointStruct.y); } private static void ModifyClassPoint(PointClass pointClass) { pointClass.x = 20; pointClass.y = 20; Console.WriteLine("Modified Valuesare {0},{1}", pointClass.x, pointClass.y); } }