You are looking in wrong direction. All you described so far is reduced to the use of the class
System.Dynamic.ExpandoObject
. Consider this, for example:
using System.Dynamic;
dynamic myObject = new ExpandoObject();
myObject.SomeProperty = "some string";
myObject.SomeOtherProperty = -13;
myObject.SomeProperty = 13.14;
This is roughly equivalent to using
loose-type typing paradigm or dynamic + duck
typing discipline, as in JavaScript.
I'm quite skeptical about practical use of such scenarios in pure-.NET systems. I could understand the merit of using compatibility with some dynamic languages effectively participating in some solution, but for pure .NET it's just the loss of strict typing, nothing else. The effect of adding property-like elements during runtime (not defined during compile time) could be easy achieved in more controllable with with the use of
associative collections (such as set, dictionary).
For some more advanced ideas, look at this CodeProject article:
How to create dynamic properties for existing class. (New to system.dynamics)[
^].
—SA