Initialize VAR in C# Programming

While working with var in c#, if you need to initialize var, it can be simply done by the following:

  1. var qq=null;  
If we will run the above code snippet, the following error will occur.

Image 1.

So to solve this use initialize your var as in the following screenshot.

As you can in the following, we will store a List in var:

Image 2.

It depends what you want to store in your list. Use the following if you want string:
  1. string y = null;  
  2. var qq = y;  


Next Recommended Reading Var and Dynamic keyword in C#