0

I need to retrieve items from ObservableCollection and add it to List<> variable and I am doing it in following way-

public class getEmployeewiseRecord
    {
        public List<string> uid { get; set; }
        public string fromdate { get; set; }
        public string todate { get; set; }
    }
public  class empList_Model
    {
        public string empName{ get; set;}
        public Boolean check{ get; set;}            
        public string id{ get; set;}
    }   

I have above models and I create a object of getEmployeewiseRecord type and set its value as shown below-

ObservableCollection<empList_Model> generateEmpList = new ObservableCollection<empList_Model>();       


    obj = new getEmployeewiseRecord ();
    obj.fromdate = fromDatePicker.Date.ToString();
    obj.todate = toDatePicker.Date.ToString ();
    foreach (empList_Model user in generateEmpList) {
                    obj.uid.Add ("user.id.ToString()");//Error : Object reference is not set to an instance of object(app crashes)
                }

I don't why such error is introduced.

Dipak
  • 1,199
  • 4
  • 21
  • 43

0 Answers0