如题,我想得到这样一个二维数组:
1    2
3    4
5    6
7    8
9    10
11   12
...
这个二维数组的列数是固定为2的,但是行数不确定。
我上网查了说用arraylist或者list,可是没找到明确的代码,请大家回复时能不能给出明确的代码呢?谢谢了

解决方案 »

  1.   

    那你用List<int[]> 好了。
      

  2.   


    嗯,用list<string[]>或者arraylist都行,但是我写的代码添加完了,存放在arraylist里的全为最后一个,大侠你能写下代码么?
      

  3.   

    List<string[]> test = new List<string[]>();
                for (int i = 1; i <= 10; i+=2)
                {
                    string[] temp = new string[] { i.ToString(), (i + 1).ToString() };
                    test.Add(temp);
                }你可以把你的代码贴出来,让大家帮你看看错在哪里。
      

  4.   

    定一个实体类
    class  cc
    {
       public int a1{get;set;}
       public int a2{get;set;} 
    }
    List<cc> lc=new List<cc>();
    lc.Add(new cc{a1=1;a2=2})
    ......
      

  5.   

    那就就用泛型好了  List<T> 
          
      

  6.   

    private List<string[]> input_list_name_seq = new List<string[]>();
    protected bool check()
    {
    if (flag)
            {
                string input_text = tbox_input.Text;
                
                lines = input_text.Split(new string[] { "\r\n" }, StringSplitOptions.RemoveEmptyEntries);
                int hang = -1;
                string[] arr_input_name_seq = new string[2];
                for (int h = 0; h < lines.Length & hang<100; h++)
                {
                    //if (lines[h] == "\r") continue;
                    
                    if (lines[h].Substring(0, 1) == ">")
                    {
                        
                        if (hang != -1&arr_input_name_seq[1]!=null)
                        {
                            if (arr_input_name_seq[1].Length - k < lamat)
                            {
                                this.ClientScript.RegisterStartupScript(this.GetType(), "alert", "<script>alert('Please correct input Lambda parameter,it should be short than cds'length - k')</script>");
                                return false;
                            }
                            input_list_name_seq.Add(arr_input_name_seq);
                        }
                        hang++;
                        arr_input_name_seq[0] = lines[h];
                        arr_input_name_seq[1] = "";
                    }
                    else
                    {
                        arr_input_name_seq[1] += lines[h];
                    }
                }        }
    }