c# list of properties from list of objects
List<string> firstNames = people.Select(person => person.FirstName).ToList();
c# list of properties from list of objects
List<string> firstNames = people.Select(person => person.FirstName).ToList();
c# get property type of list
var obj = new PropClassDemo();
foreach (PropertyInfo prop in obj.GetType().GetProperties())
{
if(prop.PropertyType != typeof(string) && typeof(IEnumerable).IsAssignableFrom(prop.PropertyType))
{
Console.Writeline("This prop's type is Ienumerable");
}
}
//Note: string is an ienumerable too
Copyright © 2021 Codeinu
Forgot your account's password or having trouble logging into your Account? Don't worry, we'll help you to get back your account. Enter your email address and we'll send you a recovery link to reset your password. If you are experiencing problems resetting your password contact us