You can simply use this:
Dictionary<int, Dictionary<string, string>>
Use it like this:
var dd = new Dictionary<int, Dictionary<string, string>>();
dd[5] = new Dictionary<string, string>();
dd[5]["a"] = "foo";
You can also create a new class to simplify the creation of the inner dictionary:
class DDict { // optional: generic
private readonly Dictionary<int, Dictionary<string, string>> _Inner = new ...;
public Dictionary<string, string> this (int index) {
Dictionary<string, string> d;
if (!_Inner.TryGetValue(index, out d)) {
d = new Dictionary<string, string>();
_Inner.Add(index, d);
}
return d;
}
}
var dd = new DDict();
dd[5]["a"] = "hi";
If the first index is sequential, you can of course also just use an array of dictionaries:
var dd = new Dictionary<string, string>[128];
Also, if the inner members are always the same, I suggest to create a new class and access it in an array:
class Dat {
string name;
string phone;
}
var list = new Dat[128]
// access:
list[5].name = "matt";
Instead of an array, you could also use a List or a Dictionary<int, Dat> in that case.