This question already has an answer here:

I am trying to add values to dictionary. Here is my code :-

public class EmpModel
{
    ....
    public Dictionary<String, String> EmpColumns { get; set; }
}

Controller

EmpModel model = new EmpModel();
model.EmpColumns.Add("one", "1"); // It gives error here

An exception of type

System.NullReferenceException

Why i am getting this error? How to solve this?

Related posts

Recent Viewed