C# already provides basic types such as:
int
double
bool
string
A class lets a programmer define a custom type that represents a concept needed by the application.
For a soccer program, useful custom types might include:
Player
Team
Match
These names represent domain concepts rather than built-in numeric or text categories.
If Player is a class, C# can use Player as a type:
Player player1 = new Player();
Read:
Player
as:
this variable/reference is intended to work with a Player object
The class definition gives the custom type meaning.
A Player concept may need:
name
jerseyNumber
isAvailable
team
Instead of treating those values as unrelated pieces of data, the Player type groups them under one software concept.
An object of that type can then carry a coherent Player state.
Player is the type.
player1 is a reference name.
new Player() creates an object instance.
Keep the three roles distinct:
Player → custom type
player1 → reference name
new Player() → object creation
Player player1 = new Player();
Player player2 = new Player();
Both objects share the same custom type.
Their field values can differ.
A class lets the program define common structure once and reuse it across many instances.
Compare:
string value1;
string value2;
with:
Player player1;
Team team1;
The custom types communicate more about the roles of the values.
They make the program's structure easier to relate to the system being modeled.
A UML class box named:
Player
represents the custom type.
An object diagram header:
player1 : Player
means that player1 is an instance of that type.
The same type concept connects UML and C#.