How to create a 1-Dimensional Array in C# with index starting at 1

前端 未结 4 1370
花落未央
花落未央 2021-01-01 20:59

For multidimensional arrays Array.CreateInstance can be used to create non-zero index based arrays, but if you try that for a 1-dimensional arrays (vectors) as in e.g.:

4条回答
  •  佛祖请我去吃肉
    2021-01-01 21:57

    All arrays in C# are zero based. As far as I know there is no way to create a 1 based array. Imagine what kind of a mess would have happened if that was possible. Here is a similar thread which explains the issue with more details - C#: Nonzero-based arrays are not CLS-compliant

提交回复
热议问题