Struct - Simple
/*
• A struct stores data in its type.
• Simple value types such as int, bool and char are structs
• Uses syntax similar to a class
• But is called a type definiton
E.g., simple struct which stores three values, an int , a bool and a double.
Note in Main the struct is created on the stack and no new keyword is used.
*/
//using System;
class Program
{
struct Simple
{
public int Position;
public bool Exists;
public double LastValue;
};
static void Main()
{
//create a struct on the stack
Simple s;
s.Position = 1;
s.Exists = false;
s.LastValue = 5.5;
Console.WriteLine(s.Position);
Console.WriteLine(s.Exists);
Console.WriteLine(s.LastValue);
}
}