Defining Fields

Fields are defined using standard variable declaration format (with optional initialization), along with the modifiers discussed previously:

class MyClass
{
    public int MyInt;
}

Fields can also use the keyword readonly , meaning that the field may be assigned a value only during constructor execution or by initial assignment:

class MyClass
{
    public readonly int MyInt = 17;
}

fields may be declared as static using the static keyword:

class MyClass
{
    public static int MyInt;
}