How can you assign a value to a variable in C#?
Experience Level: Junior
Tags: C#
Answer
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.
Related C# job interview questions
How can you find out what is the variable type?
C# JuniorHow can you declare a variable?
C# JuniorWhat is a 'var' keyword in C# good for?
C# JuniorWhat is a variable?
C# JuniorWhat is the 'new' keyword used for in C#?
C# Junior