Variables & Data Types in C#
Introduction
In this lesson, you will learn variables and data types in C# for beginners. These are the basic building blocks of any program.
What is a Variable?
A variable is used to store data in a program.
Example: storing age, name, marks, etc.
Syntax of Variable
int age = 25;
int→ data typeage→ variable name25→ value
Common Data Types in C#
| Data Type | Example |
|---|---|
| int | 10 |
| float | 10.5 |
| double | 20.99 |
| char | ‘A’ |
| string | “Hello” |
| bool | true |
Example Program
using System;
class Program
{
static void Main()
{
int age = 22;
string name = “Rahul”;
Console.WriteLine(name);
Console.WriteLine(age);
}
}
Output
Rahul
22
22
Real-World Use
- Store user data (name, email)
- Store product price in e-commerce
- Store marks in student systems
Key Points
- Variables store data
- Data types define type of data
- C# is strongly typed language
Internal Link
- Course Page: .NET Course for Beginners



