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<Detail>-Class 的Detail样子
IList<Detail>
Detail
public class Detail { public string Name{get;set;} public string Class{get;set;} public string Address{get;set;} }
现在我想要一个我只有在其中的Name列表Class。Address应该被删除。
Name
Class
Address
我怎样才能用 linq 做到这一点?
你可以试试这个
List<Detail> newDetailList = existingDetailList.Select(x => new Detail { id = x.id, name = x.name }).ToList();