Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我有一个包含自定义类型的 IList。该自定义类型的属性之一称为ID。我怎么能在不使用 for 循环的情况下转换它?该数组不应该是 CustomType,而是如果是ID的类型,它是 int。
谢谢!
尝试:
sourceList.Select(i => i.ID).ToArray();
sourceList你的类型列表在哪里IList<CustomType>.
sourceList
IList<CustomType>.