为啥这个数组中最后只有一个值(后面的值覆盖了前面的值)

Xuon Xuon 墨衍会员 · AI 创作全网分发 墨衍智能分发 通过墨衍一键同步至各平台 可同步平台 CSDN微信公众号微博知乎掘金百家号博客园抖音小红书 你的文章也可以这样分发 墨衍会员 ¥399起/年,写一次发全网 我也要 + 加入社区
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ConsoleTets
{
class Program
{
static void Main(string[] args)
{
string srcStr = "新洲区_武汉,黄浦区_上海,洪山区_武汉,崇安区_无锡,黄陂区_武汉,滨湖区_无锡";
string cityName = "武汉,无锡,上海";

string[] citysArr = cityName.Split(',');
IEnumerable<string>[] areaName = new IEnumerable<string>[citysArr.Length];
int count = 0;
for(;count<citysArr.Length;count++)
{
areaName[count] = srcStr.Split(',').Where(a => a.Contains(citysArr[count])).Distinct();
}
//Console.WriteLine(count);
Console.Read();
}
}
}


最后areaName[0],areaName[1],areaName[2]的值都为"黄浦区_上海",值类型、引用类型的问题么?
...全文

相关推荐

评论 9
收藏 已收藏
分享
返回顶部
Xuon
C# 111,130 成员 642,541 内容