开发者

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

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜