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;



Categories: C#

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s