Inside a class, a field declaration tells C#:
Example:
public int jerseyNumber;Read it as:
A simple class can contain:
class Player
{
public string name;
public int jerseyNumber;
public bool isAvailable;
}The fields belong to Player objects because they are declared inside the Player class.
This:
public int jerseyNumber;defines a field.
This:
player1.jerseyNumber = 7;assigns a value to the field on one object.
Definition and runtime assignment are separate steps.
If the class diagram shows:
jerseyNumber : intdeclare:
public int jerseyNumber;If it shows:
isAvailable : booldeclare a compatible Boolean field.
For:
team : Teama C# field can be:
public Team team;That field can later refer to a Team object.
Declaring the field does not create the Team automatically.