我有一堂课
class Test
{
public string FirstProp { get; set; }
public string SecondProp { get; set; }
public string ThirdProp { get; set; }
}
和对象列表
var list = new List<Test>
{
new Test { FirstProp = "xxx", SecondProp = "x2", ThirdProp = "x3" },
new Test { FirstProp = "xxx", SecondProp = "x21", ThirdProp = "x31" },
new Test { FirstProp = "yyy", SecondProp = "y2", ThirdProp = "y3" },
new Test { FirstProp = "yyy", SecondProp = "y21", ThirdProp = "y31" },
new Test { FirstProp = "xxx", SecondProp = "x22", ThirdProp = "x32" },
};
我需要选择第一个 FirstProp 记录:
FirstProp = "xxx", SecondProp = "x2", ThirdProp = "x3"
FirstProp = "yyy", SecondProp = "y2", ThirdProp = "y3"
如何以最好的方式使用linq
?