C# is a strongly typed programming language.
That means values, variables, and fields are associated with types that describe what kind of information they can hold.
You have already modeled information such as:
Now you can connect those ideas to basic C# types.
string Stores TextUse string for text.
Example:
string playerName = "Jordan";
The type is:
string
The variable name is:
playerName
The current value is:
"Jordan"
Quotation marks indicate a string literal.
Other soccer examples include:
string teamName = "Wildcats";
string opponentName = "Rangers";
int Stores Whole NumbersUse int for whole-number values within its supported range.
Example:
int jerseyNumber = 7;
Other examples:
int goals = 3;
int playerCount = 18;
These values do not require a fractional part.
double Stores Numbers With Fractional ValuesA simple introductory type for measurements with a fractional part is double.
Example:
double heightMeters = 1.82;
Another example:
double distanceMeters = 12.5;
A double can represent many fractional numeric values.
Later programming work may introduce more detail about numeric precision and specialized numeric types.
For now, focus on choosing a type that can represent the needed value.
bool Stores true or falseA Boolean type in C# is:
bool
Example:
bool isAvailable = true;
or:
bool hasStarted = false;
The values are written without quotation marks.
This is different from the strings:
"true"
"false"
which are text.
Consider:
int jerseyNumber = 7;
You can read it in three parts.
Type
int
Name
jerseyNumber
Initial value
7
Likewise:
bool isAvailable = true;
means:
Create a Boolean variable named
isAvailableand give it the valuetrue.
If a variable is declared as:
int goals = 3;
the program expects whole-number int values for that variable.
A text value such as:
"three"
does not match the type.
The compiler can detect many type mismatches before the program runs.
That is one way type information supports correctness.
A UML class attribute might show:
jerseyNumber : int
A C# class could later contain a corresponding field:
int jerseyNumber;
Likewise:
isAvailable : bool
can connect to:
bool isAvailable;
The UML and C# are different representations, but the type meaning can remain aligned.
A simple soccer model might use:
string playerName = "Jordan";
int jerseyNumber = 7;
double heightMeters = 1.82;
bool isAvailable = true;
Each type matches the kind of information being stored.
Do not choose a type because it makes one example convenient.
Choose it because it represents the information correctly.
At this point, the goal is not to memorize every type C# supports.
Focus on four common choices:
string — text;int — whole numbers;double — numeric values that may contain a fractional part;bool — true/false state.Those four types are enough to connect the modeling ideas in this module to simple C# information storage.