我创建如下的多维数组:
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("");
}
答案 0 :(得分:0)
听起来像谦虚的循环工作!
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]}");
}
}
}