string tmp=string.Empty;
for(int i=0;i<substring.length;i++){
if(substring[i]!=a){
tmp+="_"+substring[i];
}
}

解决方案 »

  1.   

    int[] substring = new int[] { 1, 2, 3, 4, 5, 6 };            int _Index = Array.IndexOf(substring, 6);
                if (_Index == -1)
                {
                    //没有6
                }
                else
                {
                    string _ValueText = "";
                    for (int i = 0; i != substring.Length; i++)
                    {
                        if (i == _Index) continue;
                        _ValueText += "_" + substring[i].ToString();
                    }                MessageBox.Show(_ValueText);
                }这样?
      

  2.   

    int[] substring = new int[] { 1, 2, 3, 4, 5, 6 };             int _Index = Array.IndexOf(substring, 6); 
                if (_Index == -1) 
                { 
                    //没有6 
                } 
                else 
                { 
                    string _ValueText = ""; 
                    for (int i = 0; i != substring.Length; i++) 
                    { 
                        if (i == _Index) continue; // 如果等与6,不做加_的操作
                        _ValueText += "_" + substring[i].ToString(); 
                    }                 MessageBox.Show(_ValueText); 
                } 
      

  3.   

    不对啊,报错说+=这个符号无效啊
    invalid
      

  4.   

    把4楼的 continue 改成break就OK了
    一不小心写成死循环了,呵呵
      

  5.   


    偶尔在线,呵呵,不过帮人还挨骂,比较郁闷呢http://topic.csdn.net/u/20090708/08/a927b058-157c-470a-bf6d-4f916659ddf0.html
      

  6.   

    using System.Collections;        private string Fun(int iInput)
            {
                ArrayList alList = new ArrayList();
                for (int i = 0; i < 7; i++)
                {
                    alList.Add(i);
                }
                if (iInput > 0 && iInput < 7)
                {
                    alList.Remove(iInput);
                    string szOutput = "";
                    for (int i = 0; i < 6; i++)
                    {
                        szOutput += "_" + alList[i].ToString();
                    }
                    return szOutput;
                }
                else
                {
                    MessageBox.Show("错误的输入!");
                    return "";
                }
            }
    写个函数给你试试看吧
      

  7.   


           int[] ii = new int[] { 1, 2, 3, 4, 5, 6 };
                string str = ii.Where(i => i != 6).Aggregate("_",
                    (s, i) => string.Format("{0}{1}{2}", s, i.ToString(), "_"), 
                    s=> s.TrimEnd('_'));