In C # I only see one way, create a structure of your own that does it for you. You can not use anything that already exists directly, array , List
, nothing. Everything starts from scratch. It might have some ready structure that works differently, but I do not remember anything standard and I doubt you have it in .Net.
Simplified example of what you can have in your own type:
public class MyList<T> : List<T> {
public T this[int index] {
get {
return base[index - 10];
}
set {
base[index - 10] = value;
}
}
}
I found a answer in SO with a more complete implementation on the one hand, more limited on the other.
I found this answer in the SO that gives another solution, but it's really bad to use that.
Another solution that is not ideal: you can simply leave the first 10 elements empty. Make a calculation before using the index. Resolve, but not transparently.
I would simply avoid this. Perhaps with a more comprehensive description of the problem, the solution should be another.