C# uses similar-looking symbols for two very different operations.
=stores a value.
==asks whether two values are equal.
Keeping those operations separate is essential for reading and writing conditional logic.
Consider:
player1.jerseyNumber = 7;Read it as:
The statement changes the field's state.
The single equals sign does not ask a question.
Consider:
player1.jerseyNumber == 7Read it as:
The expression evaluates to:
trueor:
falseThat makes it suitable for an if condition.
player1.isAvailable = true;Meaning:
player1.isAvailable == trueMeaning:
The first changes state.
The second inspects state.
For example:
if (player1.jerseyNumber == 7)
{
System.Console.WriteLine("Number 7 selected.");
}The condition:
player1.jerseyNumber == 7asks a question whose answer is true or false.
That is exactly what the if statement needs.
If:
player1.isAvailableis already a Boolean field, this is clear:
if (player1.isAvailable)
{
System.Console.WriteLine("Available");
}You do not always need:
if (player1.isAvailable == true)Both forms can communicate a Boolean condition, but the direct form is often easier to read.
You previously saw:
if (player1.position == "Goalkeeper")
{
System.Console.WriteLine("Goalkeeper selected.");
}The double equals sign compares the current string value with the expected string.
It does not assign "Goalkeeper" to the field.
You also saw:
if (player1.team == null)
{
System.Console.WriteLine("No team assigned.");
}Again:
==asks a question.
It does not make the Team reference null.
When you encounter an equals-looking symbol, stop and identify it.
=Think:
==Think:
This simple reading habit prevents many beginner mistakes.
For example:
player1.jerseyNumber = 7;
if (player1.jerseyNumber == 7)
{
System.Console.WriteLine("Number confirmed.");
}First, the program changes the field.
Then it evaluates whether the field equals 7.
The two statements have related values but different purposes.
Keep this sentence in mind:
Assignment changes a value. Equality compares values.
That distinction supports every conditional expression you write later.