Amin Soraya

Amin Soraya

  • NA
  • 11
  • 2.2k

how get list of data of T variable

Oct 21 2018 8:14 AM
hi there
how to send a list of specific class to such method:
 
  1. public static DataTable SetPropertyToDataTable<T>(T dataList,Type _class) where T : class  
  2.        {  
  3.            Dictionary<stringobject> columns = new Dictionary<stringobject>();  
  4.   
  5.            var properties =_class.GetProperties();   
  6.   
  7.            foreach (var item in dataList)  
  8.                foreach (var property in properties)  
  9.                {  
  10.                    var name = property.Name;  
  11.                    var value = property.GetValue(item, null);  
  12.   
  13.                    if(!columns.ContainsKey(name))  
  14.                        columns.Add(name, value);  
  15.                }  
  16.   
  17.            return ImportPropertyAndValues(columns);   
  18.        }  
 
 
I mean T datalist 

Answers (1)