如何使用此词典中的linq获取所有"列".
Dictionary<int, Dictionary<int, string>> _cells;
Run Code Online (Sandbox Code Playgroud)
我可以通过这种方式访问一行
var someRow = _cells[2];
Run Code Online (Sandbox Code Playgroud)
我能得到一个牢房
string cell = _cells[2][2];
Run Code Online (Sandbox Code Playgroud)
我想要做的是创建表.
A | B | C | ...
1 | * | * | * | ...
2 | * | * | * | ...
3 | * | * | * | ...
Run Code Online (Sandbox Code Playgroud)
我从哪里得到A栏的值.
也许这就是你要找的东西?
Dictionary<int, Dictionary<int, string>> _cells;
int desiredColumn = 2;
var col = _cells.Values.Select(d => d[desiredColumn]);
Run Code Online (Sandbox Code Playgroud)
这将遍历行(内部字典)并简单地拉出所需列的值.