Hi
When I make an array it allways starts indexing from 0.
How do I make it start on 1 instead in C#?
I want my array to go from 1 to 5 instead of 0 to 4
Sorry if this is a stupid question but I can't seem to find this anywhere.
Thanks!
where the expression-list specifics how many elements in each dimension, not their starting & ending indices.
However, you can use the System.Array.CreateInstance() method to create a System.Array (not the same as a C# array, but sometimes convertible to/from one) that starts somewhere other than 0. It's method signature is:
MSDN said:
public static Array CreateInstance(
Type elementType,
int[] lengths,
int[] lowerBounds
);
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.