Variables and Data Types in C#
Variables are used to store data in memory for use in a C# program. C# is a strongly typed language, so every variable must have a data type. Common data types include int, double, string, char, bool, etc.
Example
int age = 25;
string fullName = "Alice Smith";
bool isStudent = true;
float height = 5.9f;
char grade = 'A';
Console.WriteLine("Name: " + fullName);
Console.WriteLine("Age: " + age);
Console.WriteLine("Student: " + isStudent);
Console.WriteLine("Height: " + height + "ft");
Console.WriteLine("Grade: " + grade);
Summary
Understanding variables and data types is fundamental in any programming language.
This section teaches how to store, access, and manage different types of data in C#.
Example
const double PI = 3.14159;
Console.WriteLine("Value of PI is: " + PI);