Abhilash J A

Abhilash J A

  • NA
  • 2.4k
  • 582.4k

error - add list items to the static class variable C#

Dec 22 2016 8:56 AM
I want to get list listview items in the static class. Because I want to pass this class variable to another class. So I have tried... 
  1. public static class FileMngUserID  
  2.        {  
  3.            public static List<int> UserId;  
  4.            public static List<string> ImgName;  
  5.        }  
  6.   
  7. foreach (DocumentsUser item in listView1.SelectedItems)  
  8.            {  
  9.                FileMngUserID.UserId.Add(Convert.ToInt32(item.UserId));  
  10.                FileMngUserID.ImgName.Add(item.Parent_File_Name);                
  11.            }  
 but here  FileMngUserID.UserId.Add(Convert.ToInt32(item.UserId)); occurring error 'Object reference not set to an instance of an object.

Answers (5)