a="1,2,3,4,5,6"
b="1,4"
我想得到c(c是将a中数字过滤掉b中数字得到的结果)
c="2,3,5,6"
小弟初学 ,请详解 

解决方案 »

  1.   


    string a="1,2,3,4,5,6";
    string b = "1,4";List<string> listA = new List<string>(a.Split(','));
    List<string> listB = new List<string>(b.Split(','));List<string> listC = listA.Except<string>(listB).ToList();
      

  2.   

                
    string a = "1,2,3,4,5,6";
                string b = "1,4";
                string c = string.Join(",", a.Split(',').Except(b.Split(',')));
                Console.WriteLine(c11);//2,3,5,6
      

  3.   

    Console.WriteLine(c);//2,3,5,6
      

  4.   


       string a = "1,2,3,4,5,6";
                string b = "1,4";
                a = string.Join(",", a.Split(',').Except(b.Split(',')).ToArray());
      

  5.   

    将a、b的内容都分割开来,然后找a中是否有b的元素,有的话用""替换就是
      

  6.   


    string txta = "", txtb = "", cc = "";
            txta = a.Text.Trim().Trim(',');
            txtb = b.Text.Trim().Trim(',');
            string[] pp = txtb.Split(',');
            cc = "," + txta + ",";
            for (int i = 0; i < pp.Length; i++)
            {
                if (cc.Contains("," + pp[i] + ","))
                {
                    txtb = pp[i] + ",";
                    txta = txta.Replace(txtb, "");
                }
            }
            c.Text = txta.ToString();小弟不才给你回复一个!
      

  7.   

    private ArrayList aad()
        {
            string a = "1,2,3,4,5,6";
            string b = "1,4";
            string[] arra = a.Split(',');
            string[] arrb = b.Split(',');
            ArrayList newlist=new ArrayList();
            foreach (string temp in arra)
            {
                if (!b.Contains(temp))
                {
                    newlist.Add(temp);
                }
            }
            return newlist;
        }
      

  8.   

    查找--》替换--》填到新的string[] Arr中
      

  9.   

    var aaa = new string("123456789".ToArray().Except("159".ToArray()).ToArray()); 
    公历→农历
    2013年06月06日
    双子座
    二〇一三年四月廿八
    癸巳〖蛇〗 丁巳月 癸卯日 壬亥时
    今属:水;五行:水火木;缺:土金。