Just select the desired property from the list:
var items = new List<Item>();
var names = items.Select(x => x.Name);
var descriptions = items.Select(x => x.Description);
Update:
To do this, you need a little thought:
var names = items.Select(x => x.GetType().GetProperty("Name").GetValue(x));
Throw this into a reuse method:
public IEnumerable<object> GetColumn(List<Item> items, string columnName)
{
var values = items.Select(x => x.GetType().GetProperty(columnName).GetValue(x));
return values;
}
, , . NullReferenceException, . IEnumerable<object>, ToString() , ToString() GetValue(x):
public IEnumerable<string> GetColumn(List<Item> items, string columnName)
{
var values = items.Select(x => x.GetType().GetProperty(columnName).GetValue(x).ToString());
return values;
}
:
var items = new List<Item>();
var result = GetColumn(items, "Name");