Back to course

Structs: Value Types

C# Zero to Hero: Comprehensive Programming Masterclass

Structs

A struct is similar to a class but it is a Value Type (stored on the Stack), while a class is a Reference Type (stored on the Heap).

Use Cases

Use structs for small, lightweight data structures like Point, Coordinate, or Color.

csharp struct Point { public int X; public int Y; }

Note: Structs do not support inheritance.