比如:有个二维数组:
int[,] a = new int[3,2]{{1,2},{3,4},{5,6}}; 
如果用List,怎么弄?

解决方案 »

  1.   

    (1)使用 Tuple<int, int>(x, y)代替List。
    (2)使用 List<int[]>
    (3)使用稀疏方式保存数组:
    Tuple<int, int, int>(col, row, value)
    或者 List<Node>,其中Node是 
    class Node
    {
        public int Col { get; set; }
        public int Row { get; set; }
        public int Value { get; set; }}
    (4)直接使用 List<int>,分为2种:
    按行存取,列为偏移,或者按列存取,行为偏移。
    比如对于  2 x 4 的数组,按行存取,找(2,2),Index 就是2 x (2 - 1) + 2 - 1。
      

  2.   

    你的目的是什么?要把二维数组放到List<int>里?