我想从列表中删除重复项,而不更改列表中唯一元素的顺序.
Jon Skeet和其他人建议使用以下内容
list = list.Distinct().ToList();
Run Code Online (Sandbox Code Playgroud)
是否保证独特元素的顺序与以前相同?如果是,请提供一个确认的参考,因为我在文档中找不到任何内容.
我对cq的linq查询很新.我有一个字符串列表,我想获得一个新列表或删除所有双字符串.
List<string> zipcodes = new List<string>();
zipcodes.Add("1234");
zipcodes.Add("1234");
zipcodes.Add("1234");
zipcodes.Add("4321");
zipcodes.Add("4321");
List<string> groupbyzipcodes =
(from zip in zipcodes
group zip by zip into newgroup
select newgroup.ToList());
Run Code Online (Sandbox Code Playgroud)
无法隐式转换
'System.collection.Generic.IEnumarable<System.Collections.Generic.List<string>'为'System.collections.Generic.List<string>.存在显式转换(您是否错过了演员?)