C# overloading index operator
class MyClass
{private readonly Dictionary<string,object> data = new Dictionary<string,object>();public object this [string index]{set{ data[index] = value; }get{ return data[index]; }}public static void Main(){MyClass me = new MyClass();
me["test"] = "sample value";Console.WriteLine(me["test"]);
}}
Comments
Post a Comment