次のような動的クラスを作成したいと思います。
キーが整数で、値が文字列である辞書があります。
Dictionary<int, string> PropertyNames = new Dictionary<int, string>(); PropertyNames.Add(2, "PropertyName1"); PropertyNames.Add(3, "PropertyName2"); PropertyNames.Add(5, "PropertyName3"); PropertyNames.Add(7, "PropertyName4"); PropertyNames.Add(11,"PropertyName5");
このディクショナリを、プロパティをクラス インスタンスに構築するクラス コンストラクタに渡したいと思います。そして、これらの各プロパティに対して get 機能と set 機能の両方が必要だとします。例えば:
MyDynamicClass Props = new MyDynamicClass( PropertyNames ); Console.WriteLine(Props.PropertyName1); Console.WriteLine(Props.PropertyName2); Console.WriteLine(Props.PropertyName3); Props.PropertyName4 = 13; Props.PropertyName5 = new byte[17];
DLRを理解できません。