C#-Linq源码解析之Concat

前言

在Dotnet开发过程中,Concat作为IEnumerable的扩展方法,十分常用。本文对Concat方法的关键源码进行简要分析,以方便大家日后更好的使用该方法。

使用

Concat 连接两个序列。

假如我们有这样的两个集合,我们需要把两个集合进行连接!

List<string> lst = new List<string> { "张三", "李四" };
List<string> lst2 = new List<string> { "王麻子" };
  • 不使用Linq

大概会这样写!

    private List<string> Concat(List<string> first, List<string> second)
    {
          if (first == null)
            {
                throw new Exception("first is null");
            }

            if (second == null)
            {
                throw new Exception("second is null");
            }
            List<string> lstAll = new List<string>();
            foreach (var item in f
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值