What is a 'var' keyword in C# good for?
Experience Level: Junior
Tags: C#
Answer
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# JuniorHow can you assign a value to a variable in C#?
C# JuniorWhat is a variable?
C# JuniorWhat is the 'new' keyword used for in C#?
C# JuniorHow can you assign a value to a property in C#?
C# Junior