1.调用

var aaa = new List<string>() { "0" };

var a1 = new List<string>() { "1" };
var a2 = new List<string>() { "2" };
var a3 = new List<string>() { "3" };
var a4 = new List<string>() { "4" };
var a5 = new List<string>() { "5" }; var b = aaa.MyConcat(a1, a2, a3, a4, a5);
int count = b.Count();

2.方法

/// <summary>
/// 扩展方法必须在静态类中
/// </summary>
public static class Test
{
/// <summary>
/// 拼接(扩展方法) 只要是 实现了 System.Collections.IEnumerable 接口 的都可以调用. 比如list ,Array 等等,下面的图片是举例
/// </summary>
public static IEnumerable<TSource> MyConcat<TSource>(
this IEnumerable<TSource> thisEnumerable,
IEnumerable<TSource> one,
IEnumerable<TSource> two,
IEnumerable<TSource> three,
IEnumerable<TSource> four,
IEnumerable<TSource> five)
{
foreach (var item in thisEnumerable) yield return item;
foreach (var item in one) yield return item;
foreach (var item in two) yield return item;
foreach (var item in three) yield return item;
foreach (var item in four) yield return item;
foreach (var item in five) yield return item; //按照实际需求继续写下去,也可以 用重载,
//System.Linq.Enumerable 类库中有1个参数的扩展方法,叫做 Concat,
//所以 把方法名 写成Concat 然后 写出 23456个参数的扩展方法.就可以了.
}
}

  

举例

3.结果

多个List 或 Array 进行 合并的更多相关文章

  1. Leetcode#88. Merge Sorted Array(合并两个有序数组)

    题目描述 给定两个有序整数数组 nums1 和 nums2,将 nums2 合并到 nums1 中,使得 num1 成为一个有序数组. 说明: 初始化 nums1 和 nums2 的元素数量分别为 m ...

  2. 【leetcode】Merge Sorted Array(合并两个有序数组到其中一个数组中)

    题目: Given two sorted integer arrays A and B, merge B into A as one sorted array. Note: You may assum ...

  3. LeetCode第[88]题(Java):Merge Sorted Array(合并已排序数组)

    题目:合并已排序数组 难度:Easy 题目内容: Given two sorted integer arrays nums1 and nums2, merge nums2 into nums1 as ...

  4. [LC]88题 Merge Sorted Array (合并两个有序数组 )

    ①英文题目 Given two sorted integer arrays nums1 and nums2, merge nums2 into nums1 as one sorted array. N ...

  5. LeetCode 88. Merge Sorted Array(合并有序数组)

    Given two sorted integer arrays nums1 and nums2, merge nums2 into nums1 as one sorted array. Note:Yo ...

  6. LeetCode OJ:Merge Sorted Array(合并排序的数组)

    Given two sorted integer arrays nums1 and nums2, merge nums2 into nums1 as one sorted array. Note:Yo ...

  7. leetCode 88.Merge Sorted Array (合并排序数组) 解题思路和方法

    Given two sorted integer arrays nums1 and nums2, merge nums2 into nums1 as one sorted array. Note: Y ...

  8. numpy.array 合并和分割

    # 导包 import numpy as np numpy.array 的合并 .concatenate() 一维数组 x = np.array([1, 2, 3]) # array([1, 2, 3 ...

  9. jQuery.merge( first, second )返回: Array

    jQuery.merge( first, second )返回: Array描述: 合并两个数组内容到第一个数组.first类型: Array第一个用于合并的数组,其中将会包含合并后的第二个数组的内容 ...

随机推荐

  1. 压测工具wrk的编译安装与基础使用

    Linux上编译安装: [root@centos ~]# cd /usr/local/src [root@centos ~]# yum install git -y [root@centos ~]# ...

  2. jQuery动画(带参数)

    <!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title> ...

  3. spring 自定义schema 加载异常 White spaces are required between publicId and systemId.

    spring 项目启动报错 报错日志如下: Caused by: org.springframework.beans.factory.xml.XmlBeanDefinitionStoreExcepti ...

  4. union 和 union all的区别

    union 和 union all的区别 相同点和不同点 相同点:union和union all 都是对于多个查询结果的并集进行操作不同点:1.union 不会输出两个结果并集的重复行2.union ...

  5. python智能提取省、市、区地址

    工具原文 https://github.com/DQinYuan/chinese_province_city_area_mapper 说明: https://blog.csdn.net/qq_3325 ...

  6. spring事务什么时候会自动回滚

    在java中异常的基类为Throwable,他有两个子类xception与Errors.同时RuntimeException就是Exception的子类,只有RuntimeException才会进行回 ...

  7. uwsgi配置文件示例

    uwsgi配置文件参考 相关路径请根据自己项目的实际路径配置 在进行Nginx+uwsgi部署Django项目的时候,需要Nginx的配置中包含uwsgi的配置项,具体请查看另一篇:Nginx配置文件 ...

  8. 【HICP Gauss】数据库 数据库管理(调优 启动流程)-4

    数据库参数: 创建数据库 调优数据库 其他---->控制资源使用 控制数据库内部机制 设置重要属性 参数数据保存在cfg/Zengine.ini 文件中 参数保存使用 key=value的保存形 ...

  9. SpringCloud2.0 Turbine 断路器集群监控 基础教程(九)

    1.启动基础工程 1.1.启动[服务中心]集群,工程名称:springcloud-eureka-server 参考 SpringCloud2.0 Eureka Server 服务中心 基础教程(二) ...

  10. 如何利用AI识别未知——加入未知类(不太靠谱),检测待识别数据和已知样本数据的匹配程度(例如使用CNN降维,再用knn类似距离来实现),将问题转化为特征搜索问题而非决策问题,使用HTM算法(记忆+模式匹配预测就是智能),GAN异常检测,RBF

    https://www.researchgate.net/post/How_to_determine_unknown_class_using_neural_network 里面有讨论,说是用rbf神经 ...