[Mono-list] adding members to a class at runtime
Yves Glodt
y.glodt at sitasoftware.lu
Mon Dec 19 15:58:18 EST 2005
Andreas Färber wrote:
> Hi Yves,
Hi Andreas, Michael
>> I need to add members to a class at runtime...
>>
>> e.g.:
>>
>> class MyClass {
>> public int var1;
>> public int var2;
>> public int var3;
>> }
>>
>>
>> E.g, now, at runtime, I need to add var4 that is a string and var5
>> that is another integer...
>>
>> Can that be done in c# at all...?
>
> I believe no. But using Reflection.Emit you can derive a class at
> runtime and add the new members and afterwards access all of them.
yes I guess that's the way to go.
Thanks for the suggestion and also to Micheal for his thoughts.
Regards,
Yves
> Regards,
>
> Andreas
More information about the Mono-list
mailing list