CodeToLive

Variables and Data Types

Variables are used to store data in a program. C# supports various data types, including integers, floating-point numbers, strings, and booleans.

Declaring Variables


int age = 25;
double price = 19.99;
string name = "Alice";
bool isActive = true;
      

Common Data Types

Type Inference with var

C# supports type inference using the var keyword.


var age = 25; // int
var price = 19.99; // double
var name = "Alice"; // string
      
Next: Operators and Expressions