C# Basics/
Variables
![Original YouTube Logo](/img/original-youtube-logo.png)
This page have a related YouTube video
- C# variables are storage locations for values in a C# program.
- They are identified by a name and a data type, and they can hold a wide range of values, including numbers, text, and more.
- C# variables are declared with a specific data type, which determines the kind of value that can be stored in the variable.
- Once a C# variable is declared, it can be used throughout the program by referencing its name.
In C#, a variable is a storage location for a value. Variables have a data type, which determines the kind of value that can be stored in the variable. Some common data types in C# include int (integer), double (floating point number), and string (text).
To declare a variable in C#, you use the following syntax:
For example, to declare an integer variable called "age", you would use the following code:
You can also assign a value to the variable when you declare it, like this:
Once a variable is declared, you can use it in your code by referencing its name. For example, to print the value of the "age" variable to the console, you would use the following code: