list截取的问题。
List<String> a = new List<string>(){ "a", "b", "c" ,"d", "e", "f"};现在list里面有6个值,有什么方法或属性可以截取list只有4个值,把值“e”和“f”干掉。
最后list结果里面是 List<String> a = new List<string>(){ "a", "b", "c" ,"d"};
--------------------编程问答-------------------- 直接移除不就行了? --------------------编程问答-------------------- 之前判断是否个数大于4个,然后
contentList.RemoveRange(4, contentList.Count - 4); --------------------编程问答-------------------- 如果指定项目移除就如下
contentList.Remove("e");
contentList.Remove("f"); --------------------编程问答-------------------- a=a.Take(4).ToList(); --------------------编程问答--------------------
这个要3.5框架的吧? --------------------编程问答-------------------- a.removeAt(4);
a.removeAt(4);
--------------------编程问答-------------------- a=a.Take(4).ToList(); --------------------编程问答-------------------- http://stackoverflow.com/questions/47752/remove-duplicates-from-a-listt-in-c --------------------编程问答-------------------- List<String> a = new List<string>(){ "a", "b", "c" ,"d", "e", "f"};
a.FindAll(delegate(string s){return Cnvert.ToInt32(s.ToCharArray()[0])<101?s:""; }) --------------------编程问答-------------------- List<String> a = new List<string>() { "a", "b", "c", "d", "e", "f" };
a = a.FindAll(delegate(string x) { return !x.Contains("e") && !x.Contains("f"); });
补充:.NET技术 , ASP.NET