在c#中获取多维数组的维数

时间:2021-03-24 21:33:58

Suppose that my function gets a two dimensional array as input and its dimensions are unknown. How can I figure them out using reflection?

假设我的函数得到一个二维数组作为输入,它的维数是未知的。我如何用反射来计算它们?

1 个解决方案

#1


6  

You don't need reflection for this.

你不需要对此进行反思。

You can call the GetLength method of the Array class and pass the dimension index.

您可以调用数组类的GetLength方法并传递维度索引。

#1


6  

You don't need reflection for this.

你不需要对此进行反思。

You can call the GetLength method of the Array class and pass the dimension index.

您可以调用数组类的GetLength方法并传递维度索引。