C#Html
Introduction to C#
Variables and Data Types in C#
Operators in C#
Control Statements in C# – if, else, switch, and loops Explained
Jump Statements in C# – break, continue, return Explained with Examples
Conditional Statements in C# if, else if, else, switch Explained with Examples
Loops in C# – For, While, and Do While with Examples

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);