Register to Better Coder! It's free.
Enjoy the premium features and succeed at every job interview.

What is a variable?

Experience Level: Junior
Tags: C#

Answer

A varialbe is a container for holding a value of a specific type.

If you want to sum two numbers, you might use 3 variables. 2 variables for holding two numbers that are to be added and one variable for storing the result.

In the following example, the number 4 is stored to the variable a. Number 6 is stored to the variable b. Then the values of these two variables are added and the result is stored to the variable c, so the variable c now holds value 10;

var a = 4;

var b = 6;

var c = a + b;

Remembner: Before you can use a variable you have to declare it.

Comments

No Comments Yet.
Be the first to tell us what you think.
C# for beginners
C# for beginners

Are you learning C# ? Try our test we designed to help you progress faster.

Test yourself