csharp / beginner
Snippet
Variables and Data Types
In C#, you must specify the type of data a variable will hold. Common types include string (text), int (whole numbers), and bool (true/false).
snippet.csharp
1
2
3
string playerName = "Alex";int playerLevel = 5;bool isOnline = true;
Breakdown
1
string playerName = "Alex";
Declares a variable that stores text strings.
2
int playerLevel = 5;
Declares an integer variable for whole numbers.
3
bool isOnline = true;
Declares a boolean variable that can only be true or false.