Use System.Collections.Generic.Dictionary<T1,T2>like others. To complete your knowledge, you must know that you can control behavior []. Example:
public class MyClass
{
public string this[string someArg]
{
get { return "You called this with " + someArg; }
}
}
class Program
{
void Main()
{
MyClass x = new MyClass();
Console.WriteLine(x["something"]);
}
}
Will produce "You called it something."
Read more about this in the documentation.
source
share