In C# I only see a way, create a structure of your own that does this for you. You cannot use anything that already exists directly, array, List
, nothing. everything starts from scratch. It may have some structure ready that works differently, but I don’t remember anything standard and I doubt it has in the . NET.
Simplified example of what you can have in your own type:
public class MyList<T> : List<T> {
public T this[int index] {
get => base[index - 10];
set => base[index - 10] = value;
}
}
I put in the Github for future reference.
I found a response in the OS with a more complete implementation on the one hand, more limited on the other.
I found this response in the OS that gives another solution, but it is very bad to use it.
Another solution that is not ideal: you can simply leave the first 10 elements empty. Make a calculation before using the index. Solve, but not transparently.
I would simply avoid this. Perhaps with a more comprehensive description of the problem, the solution should be another.
You want all array values (array) to start with a default value, this?
– Jéf Bueno
Or that the first index is 10? Please put an example of the code you want it to be possible to write...
– carlosfigueira
@jbueno not all, only one vector
– Vale