This
is a fairly simple way:
System.Array.CreateInstance
with lower bound. You can specify lower bounds even with the array rank more then 1, see
System.Array.CreateInstance(Type, Int32[], Int32[])
.
If you do this, you have to use
GetLowerBound, SetValue, GetValue
, etc. See the usage sample:
http://msdn.microsoft.com/en-us/library/system.array.getlowerbound.aspx[
^].
To my taste, it does not worth bothering, but you should decide by yourself.
If you asked about my preferences, I would always work with zero-based indexing — at lower level.
If I had a requirement to implement arbitrary indexing bases, no matter what the rank of array data is, I would create a wrapper of the array data on semantic level. In this wrapper, I would create indexed property ("this") with required types of indices. I would offset the value of integer index in the property getter/setter to achieve the effect of non-zero-based indexing. Internally, indexing would remain zero-based.
You can easily do the same. Again, decide by yourself.
—SA