【发布时间】:2013-01-18 20:01:44
【问题描述】:
KeyValuePair<int, string>[][] partitioned = SplitVals(tsRequests.ToArray());
不要太担心我使用的方法;假设我得到了一个锯齿状的 KeyValuePairs 数组,它们被平均分成不同的数组。
foreach (KeyValuePair<int, string>[] pair in partitioned)
{
foreach (KeyValuePair<int, string> k in pair)
{
}
}
我需要知道如何有效地获取 int 数组中的整数,以及从键值对数组中获取单独字符串数组中的字符串。这样,两个索引在单独的数组中相互匹配。
比如我把它拆分成一个int[]数组和一个string[]数组后,
intarray[3] must match stringarray[3] just like it did in the keyvaluepair.
假设我有一个带有 KVP 的锯齿状数组,例如:
[1][]<1,"dog">, <2,"cat">
[2][]<3,"mouse">,<4,"horse">,<5,"goat">
[3][]<6,"cow">
我需要在每次迭代中变成这个
1. 1,2 / "dog","cat"
2. 3,4,5 / "mouse", "horse", "goat"
3. 6 / "cow"
【问题讨论】:
标签: c# .net multidimensional-array jagged-arrays