Variables in C# are storage location where the data(Be it a number or a Name) is stored.It is like a container where something is stored.
Well! C# takes the same step to add two numbers. The only difference is, you have used one notebook to write and add the numbers.
But C# uses different locations to store each number. And they are called as Variables.
Let us see how Variables are used in C# for addition of two numbers.
public class MyApplication
{
public static void Main(string[] args)
{
int x = 5;
int y = 8;
int z;
z = x + y;
System.Console.WriteLine("The added value is : "+z);
}
}
Now, if you look at the above code, x, y and z are Variables.
And below are the steps involved in addition of the numbers.
int x = 5;

int y = 8;

int z;


System.Console.WriteLine("The added value is : "+z);"The added value is : "
z
"The added value is : "+z
The added value is : 13
So far we have seen, how to store a number (i.e. int x = 5) in a Variable.
Now, let us see how to store a string(i.e. It could be a Name or a City) in a Variable.
Let us say, we want to store the string Hello World in a Variable(Say x).
And the process of storing a string is same as storing a number, but with a mild difference.
Below is the C# Code :
public class MyApplication
{
public static void Main(string[] args)
{
string x = "Hello World";
System.Console.WriteLine(x);
}
}
So, in the above example, we have used String infront of the Variable x to store a String type value.

Just like any other language, there is a rule to declare the Variables.
Although, the Variables can be of any names with some restriction.
Below are the rules :
So, if you have two numbers and need to assign them to two Variables. You can either declare the variables as x and y.
And
But the preferred way to name the Variables would be firstNumber and secondNumber.
And
But you can never use Variable names with spaces like first number or Variables with a - like first-number.