数组,如何剔除元素?
string[] num = new string[] { "0", "1", "2", "3", "4", "5", "6", "7", "8", "9" };
string[] str1 = new string[] { "2", "3","6"};
string[] str2 = new string[] { "0", "3","5"};
如何从num中剔除,str1 && str2 的元素,并且显示剩下的元素
------解决方案--------------------
------解决方案--------------------string[] result = num.Except(str1.Union(str2)).ToArray();
------解决方案--------------------C# code
string[] num = new string[] { "0", "1", "2", "3", "4", "5", "6", "7", "8", "9" };
string[] str1 = new string[] { "2", "3", "6" };
string[] str2 = new string[] { "0", "3", "5" };
num = num.Except(str1).Except(str2).ToArray();
foreach (string s in num)
{
Response.Write(string.Format("{0}<br>", s));
}