Click here to Skip to main content
15,908,445 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi everyone,
I have a class which has primitive type properties and also has types like List<> of something.
At this code:
C#
string[] colums = typeof(T).GetProperties().Select(c => c.Name).ToArray();
foreach (var col in colums)
{
 var tc=  typeof(C).GetProperties().Select(c => c.Name).ToArray();
 var tp = col.GetType();
 var value = typeof(T).GetProperty(col).GetValue(item, null) ?? string.Empty;

 

}

I can get the values like this.But when it is List<> i cant.Is there any way to understand if property is List<> of something?
Posted

See here: http://stackoverflow.com/questions/1503976/determine-if-property-is-generic-listof-t-via-reflection-and-loop-list-items[^]
About half way down is a complete console app which should do what you want.
 
Share this answer
 
Comments
emrebeysungu 2-Sep-13 7:01am    
Yes thats what i looking for thanks.
you can get type of propety with:


C#
System.Reflection.PropertyInfo propertyInfo = typeof(ObjectName).GetProperty("propertyName");
Type type = propertyInfo .PropertyType;
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900