hao_2468

  博客园 :: 首页 :: 博问 :: 闪存 :: 新随笔 :: 联系 :: 订阅 订阅 :: 管理 ::
  protected string[] removeDuplicate(string[] ArrInput)
{
ArrayList nStr = new ArrayList();
for (int i = 0; i < ArrInput.Length; i++)
{
if (!nStr.Contains(ArrInput[i]))
{
nStr.Add(ArrInput[i]);
}
}
return (string[])nStr.ToArray(typeof(string));
}


//去除数组中的重复项

 


================== 发送信息,添加手机重复问题(添加的号码内部重复、添加的号码和原来的号码重复)=======================


/// <summary>
/// 得到收费用户的信息(去空格)
/// </summary>
/// <returns></returns>
public string[] getChargePhone()

string fee=  this.txtMen.Text.Trim();//原来查询的套餐收费用户
if (!fee.Equals(""))
{
string[] fe = fee.Split(';');
return this.removeDuplicate(fe);
}
return null;
}

        /// <summary>
/// 得到免费用户的信息(可能有重复)
/// </summary>
/// <returns></returns>
public string[] getFreePhone()
{
string free= this.txtAddNum.Text.Trim();//得到添加的免费用户
if(!free.Equals(""))
{
string[] fre = free.Split(';');
return this.removeDuplicate(fre);
}
return null;
}

        /// <summary>
/// 去除本数组中的重复和" "
/// </summary>
/// <param name="ArrInput"></param>
/// <returns></returns>
protected string[] removeDuplicate(string[] ArrInput)
{
ArrayList nStr = new ArrayList();
for (int i = 0; i < ArrInput.Length; i++)
{
if (!nStr.Contains(ArrInput[i])&&!ArrInput[i].Equals(""))
{
nStr.Add(ArrInput[i]);
}
}
return (string[])nStr.ToArray(typeof(string));

 

        /// <summary>
/// 得到去除重复的号码的免费号码
/// </summary>
/// <returns></returns>
public string[] getEcho()
{
if (this.getFreePhone() != null)//后来添加的
{
if (this.getChargePhone() != null)//原来查询的
{
string[] add = this.getFreePhone();
string[] old = this.getChargePhone();

                    ArrayList nStr = new ArrayList();
//先把免费的数据 添加到集合中
for (int i = 0; i < add.Length; i++)
{
nStr.Add(add[i]);
}


//和老数据比较,有重复的,删除
for (int j = 0; j < old.Length; j++)
{
if (nStr.Contains(old[j]))
{
nStr.Remove(old[j]);
}
}

return (string[])nStr.ToArray(typeof(string));
}
else//原来的为空,则添加后来增加的号码
{
return this.getFreePhone();
}
}
else
{
return null;
}
}
posted on 2009-10-23 20:26  hao_2468  阅读(274)  评论(0编辑  收藏  举报