110,547
社区成员
发帖
与我相关
我的任务
分享
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();
}
}
}
string srcStr = "新洲区_武汉,黄浦区_上海,洪山区_武汉,崇安区_无锡,黄陂区_武汉,滨湖区_无锡";
string cityName = "武汉,无锡,上海";
string[] citysArr = cityName.Split(',');
IEnumerable<string>[] areaName = new IEnumerable<string>[citysArr.Length];
int count = 0;
for (; count < citysArr.Length; count++)
{
int temp = count;
areaName[count] = srcStr.Split(',').Where(a => a.Contains(citysArr[temp])).Distinct();
}
//Console.WriteLine(count);
Console.Read();