Back to course

Variables and Basic Data Types

C# Zero to Hero: Comprehensive Programming Masterclass

Understanding Variables

A variable is a container for storing data values. In C#, every variable must have a specific type.

Common Data Types

  • int: Integers (e.g., 100, -5).
  • double: Floating point numbers (e.g., 19.99).
  • char: Single character (e.g., 'A').
  • string: Sequence of characters (e.g., "Hello").
  • bool: Boolean values (True or False).

Syntax

csharp int myAge = 25; string myName = "John"; double price = 10.50; bool isProgrammer = true;

Note: Variables in C# are case-sensitive!