Register to Better Coder! It's free.
Enjoy the premium features and succeed at every job interview.
What is a 'var' keyword in C# good for?
Experience Level: Junior
The 'var' keyword is used for declaring a variable. Before you can us a variable, you need to declare it first. When you declare a variable using the 'var' keyword, the data type of the variable
w the variable a gets declared and value 4 gets assigned to it. Because the integer value gets assigned to the variable, the variable will have data type int.
var a = 4;
Related C# job interview questions
How can you declare a variable?C# Junior
How can you assign a value to a variable in C#?C# Junior
What is a variable?C# Junior
What is the 'new' keyword used for in C#?C# Junior
How can you assign a value to a property in C#?C# Junior