Returning list of properties from a list of objects
I have a list of Tenants (call it TenantList), and it's composed of Tenant obj开发者_如何学Pythonects and they all have an ID property. How can I return an enumerable item composed of their ID properties?
You can use either
var result = TenantList.Select(t => t.ID)
or
var result = from tenant in TenantList select tenant.ID
TenantList.Select(t => t.ID)
TenantList.Select(t => t.ID);
精彩评论