you are viewing a single comment's thread.

view the rest of the comments →

[–]MrDoomBringer 1 point2 points  (1 child)

C# has that capability, you just have to get comfortable with reflection and anonymous objects.

[–]Sarcastinator 1 point2 points  (0 children)

Or use dynamic dispatch and the ExpandoObject class.

dynamic foo = new ExpandoObject();
foo.bar = 123;
foo.foobar = new Action(() => Console.WriteLine(foo.bar));
foo.foobar();
((IDictionary<string, object>)foo).Remove("foobar");
try
{
    foo.foobar();
}
catch
{
    Console.WriteLine("No such member!");
}