[英]I want to get the “Index array” from a multi-dimensional array
我创建一个多维数组,如下所示:
List<int> indexList = GetFromSomewher()
Results = Array.CreateInstance(typeof(System.Double),indexList.ToArray() );
foreach (DataRow row in table.Rows)
{
List<int> indexInstance = new List<int>();
for (int d = 0; d < DegreesOfFreedom; d++)
{
indexInstance.Add(DimDict[d][row.Field<double>(d)]);
}
Results.SetValue(row.Field<double>(DegreesOfFreedom), indexInstance.ToArray());
}
然后,一旦创建,我想查看索引数组和值。 但是这只会给我“价值”。 我可以在调试中看到索引数组-但无法访问它。
foreach (var res in Results)
{
Console.WriteLine("");
}
听起来像是谦虚的循环工作!
static void Main(string[] args)
{
int[][] test = new int[][] { new int[] { 1, 2, 3 }, new int[] { 4, 5, 6 }, new int[] { 7, 8, 9 } };
for(int i = 0; i < test.Length; i++)
{
for (int j = 0; j < test[i].Length; j++)
{
Console.WriteLine($"Index: [{i},{j}]: {test[i][j]}");
}
}
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.