What is a 'var' keyword in C# good for?

Experience Level: Junior
Tags: C#


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;


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