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

How can you assign a value to a variable in C#?

Experience Level: Junior
Tags: C#


To assign a value to a variable, use the operator '='. In the code below the value 10 will be assigned to the variable x and the value 20 will be assinged to the variable y. It's like in math. The value from the right hand side of the assignment operator '=' gets assigned to the left hand side of the assignment operator.


var x = 10;

int y;
y = 20;


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