asp.net两个数组的并集
有string[]str1={"a","b","d"}string[]str2={"a","c","d","e"}如果求得string[]str3={"a","b","c...
有
string[] str1={"a","b","d"}
string[] str2={"a","c","d","e"}
如果求得string[] str3={"a","b","c","d","e"} 展开
string[] str1={"a","b","d"}
string[] str2={"a","c","d","e"}
如果求得string[] str3={"a","b","c","d","e"} 展开
2个回答
展开全部
直接用LINQ的扩展方法很蠢神简单,
using System;
using System.Linq;
static void Main()
{
碧档升 string[] str1={"a","悔老b","d"};
string[] str2={"a","c","d","e"};
// or str3 = str1.Union(str2).ToArray();
string[] str3 = str1.Concat(str2).Distinct().ToArray();
foreach(string c in str3)
Console.WriteLine(c);
}
输出:
a
b
d
c
e
本回答被提问者采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
usin System.Linq;
string[] str1 = 纤纤{ "a", 皮竖氏"燃散b", "d" };
string[] str2 = { "a", "c", "d", "e" };
var query = str1.Union(str2).ToArray();
foreach (string str in query)
{
Console.WriteLine(str);
}
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询