合并字符串

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

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值