比如:有个二维数组:
int[,] a = new int[3,2]{{1,2},{3,4},{5,6}};
如果用List,怎么弄?
int[,] a = new int[3,2]{{1,2},{3,4},{5,6}};
如果用List,怎么弄?
解决方案 »
- c# 调用xxx.dll非托管代码
- 字符串赋值为null和Empty有什么区别
- IE和火狐 用c# 正则表达式判断中文的问题
- 求一个汽车发动机号的正则表达式
- 调用Delphi Dll 出现无法封送处理return value错误
- 窗体的 KeyPress 事件中,如何判断按键,比如判断按键是 ESC键
- 页面间传值的问题
- ce嵌入式系统与web service的一个问题
- 高手请进,为什么C#中不能取CPU的数量?
- datagrid太宽了,怎么把datagrid的横向得滚动条显示出来?
- 关于WinForm与javascript的交互问题
- C#怎么在WinForm操控Flash?能否用webbrowser
(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。