public class TestClass
{
private Dictionary<string, int> _testDictionary = new Dictionary<string,int>();
private string _key;
public int this[string key]
{
get { return _testDictionary[key];}
set
{
if (_testDictionary.ContainsKey(key))
_testDictionary[key] = value;
else
_testDictionary.Add(key, value);
}
}
}
public class Program
{
static void Main(string[] args)
{
TestClass test = new TestClass();
test["T1"] = 1;
test["T2"] = 2;
Console.WriteLine(test["T1"]);
Console.WriteLine(test["T2"]);
}
}
So how this way of defining properties is called, I want to read more about that. Also is it possible to have same definition like this in other places, for an example in Methods etc.