Programmatically Declare Array of Arbitrary Rank

后端 未结 3 564
走了就别回头了
走了就别回头了 2021-01-14 01:29

In C#, there are three types of arrays: one-dimensional, jagged, and multi-dimensional rectangular.

The question is: given an array of a specific size, how can we cr

3条回答
  •  说谎
    说谎 (楼主)
    2021-01-14 02:07

    You can use reflection-like methods:

    • Create your array instance by calling Array.CreateInstance. This will give you an instance of the Array class.
    • Call SetValue to assign values to your array.
    • Use GetValue to retrieve any elements of the array.

提交回复
热议问题