LinQ查询-转换

来源:互联网 发布:linux换行输入 编辑:程序博客网 时间:2024/06/08 10:00

List<string> listString= new List<string>{ "naio","Fithting","John","David"};

Ilist<string> newListString=( from n in arr 

where n.startWith("D")

oderby n.firstProperty,n.secondProperty

select n).tolist();


arr.add("jin");

arr.add("jinlin");

froeach( string str in newListString)

{

console.writeline(str);

}

对于listString进行Ilist转换,调用扩展方法之后,改变了数据源的名称(或引用);

造成对结果数据的遍历结果并非是数据更改后的结果。