I think these are called "associative arrays" where the index is named. No, you cannot do that with CLR arrays (out of the box), but you can achieve close to the same with a Hashtable:
- Hashtable array = new Hashtable();
-
array.Add("my_index", "my_index's value");
-
Console.WriteLine(array["my_index"]);
Also, a generic Dictionary<string, string> and several other collection types will do it.
Another option is to write your own Collection<T> and add a custom
Indexer which accepts a string index value instead of the default int.