Struct in C#

Structs are custom value types that store the values in each field together. They don’t store refereced data, such as the character array in a string. By the way, Structs can imporve speed and memory usage, and they cannot be used the same as Classes.

Example: Program that declares struct

class Program


struct Simple


public int Position;

public bool Exists;

public double LastValue;


static void Main()


Simple s;

s.Position = 1;

s.Exists = false;

s.LastValue = 3.54;