开发者

Returning list of properties from a list of objects

开发者 https://www.devze.com 2023-01-08 19:23 出处:网络
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 proper

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);
0

精彩评论

暂无评论...
验证码 换一张
取 消