类结构
public class EmployeeDetails
{
public int Id { get; set; }
public string Name { get; set; }
public string Exp { get; set; }
}
员工详细信息列表
Id Name Exp
-- --------- --------
1 Bill 2 years
2 John 5 years
3 Doug 1 years
我想删除一个字段表单列表对象,如Id
,如下输出
Name Exp
--------- --------
Bill 2 years
John 5 years
Doug 1 years
有人知道怎么做吗?
与我分享
谢谢
最佳答案
你可以试试:
var listWithoutCol = List.Select(x => new { x.Name , x.Exp}).ToList();
这将返回一个列表,其中仅包含字段 Name 和 Exp...
关于c# - 如何从列表中删除特定字段,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45476123/