摘要: 把一个数据集List<T>复制至到另一个数据集List<T>。 方法一,可以使用循环,然后把每一个T添加至另一个集合中去: public void ListDemo() { var listA = new List<int> { 2, 5, 6, 8, 23, 56, 4 }; var listB 阅读全文
posted @ 2017-12-27 21:20 Insus.NET 阅读(16937) 评论(3) 推荐(1) 编辑
摘要: 获取2个集合List<T>的共同元素,循环2个集合,然后比对。 class Bj { public void GetIntersect() { var listA = new List<int> { 2, 5, 6, 8, 23, 56, 4 }; var listB = new List<int> 阅读全文
posted @ 2017-12-27 15:50 Insus.NET 阅读(1338) 评论(0) 推荐(4) 编辑
摘要: yield是对一种复杂行为的简化,就是将一段代码简化为一种简单的形式。 先看一下常规的写法,下面例子中,把找出字符串阵列中,某些元素包含有某些字符的元素。 class Bi { public string[] str { get; set; } public IEnumerable<string> 阅读全文
posted @ 2017-12-27 13:48 Insus.NET 阅读(819) 评论(1) 推荐(1) 编辑
摘要: 循环输邮索引值,使用for是没有任何问题: class Bh { public string[] str { get; set; } public void TestFor() { for (int i = 0; i < str.Length; i++) { Console.WriteLine("i 阅读全文
posted @ 2017-12-27 10:13 Insus.NET 阅读(2510) 评论(0) 推荐(1) 编辑