string s1 = "abc;set;commlist;del;rel";
string s2 = "abc;set;mana";
string s3 = s1 + ';' +s2;
string[] s1temp = s1.Split(';');
string[] s2temp = s2.Split(';');
for(int i = 0; i < s1temp.Length; i++)
for(int j = 0; j < s2temp.Length; j++)
{
if(s1temp[i].Equals(s2temp[j]))
s2temp[j] = "";
}
for(int i = 0; i < s2temp.Length; i++)
if(!s2temp[i].Equals(""))
s1 += ';' + s2temp[i];
Console.WriteLine(s1);
Console.ReadLine();
------------------
string [] str1 = {"0","1","2","3"};
string [] str2 = {"0","3","4"};
ArrayList str3 = new ArrayList();
for (int i = 0; i < str1.Length; i++)
{
if (str3.IndexOf(str1[i],i) < 0)
{
str3.Add(str1[i]);
}
}
for (int i = 0; i < str2.Length; i++)
{
if (str3.IndexOf(str2[i],i) < 0)
{
str3.Add(str2[i]);
}
}
本文来自优快云博客,转载请标明出处:http://blog.youkuaiyun.com/yunfan555/archive/2008/11/12/3284016.aspx