1.2.3 Custom Types vs. Primitive Types

Programs Use Different Kinds of Types

C# programs work with simple built-in value types and with custom classes.

For introductory reasoning, compare:

C#
int jerseyNumber;
bool isAvailable;
double distanceMeters;

with:

C#
Player player1;
Team team1;

The first group represents basic values.

The second group represents object references to custom types.

Basic Types Represent Individual Values

Examples include:

Plain text
int    → whole-number value
double → numeric value with fractional capability
bool   → true/false value

A field such as:

C#
int jerseyNumber;

is designed to hold one whole-number value.

A Custom Class Can Represent a Structured Concept

A Player object can contain several related fields.

Conceptually:

Plain text
Player
- name
- jerseyNumber
- isAvailable
- team

That is more structured than one integer or Boolean.

The class gives the program a type for the complete Player concept.

string Is Commonly Used Like a Basic Type but Is a Reference Type

You have used:

C#
string playerName = "Jordan";

For beginner code, string often feels similar to the basic value types because you assign and display text directly.

Technically, string is a reference type in C#.

You do not need advanced memory details here.

The useful distinction is that custom classes such as Player also produce object references and can contain their own structured state.

Type Compatibility Still Matters

A field declared as:

C#
int jerseyNumber;

expects an integer-compatible value.

A field declared as:

C#
Team team;

expects a compatible Team reference.

The compiler uses type information to prevent many mismatched assignments.

Choose a Type That Matches the Information

Ask:

Is this one simple value, or is it a structured concept with its own state?

For:

Plain text
jersey number

an int may fit.

For:

Plain text
player

a custom Player class can fit.

The type should communicate the meaning of the information.

Keep the Distinction Useful

Do not reduce the topic to:

primitive = simple, custom = complicated.

A better idea is:

built-in/basic value types represent common individual values;

custom class types let the application represent concepts specific to its domain.