I have stored some C# code in a database table.
I have the whole code of a base class in a string.
With the stored C# code in hand, I add to the class a method named m1
that contains a return <<some C# code>>;
(the method always returns object
so the C# code can be: 88 + 90
, "hello world"
, this.ToString()
, etc.), save it to a file and compile it with CSharpCodeProvider
, and run it on my program.
The stored C# code can use some methods in the base class.
This scheme works very well.
Now, I would to use Reflection.Emit
to do this, to avoid the compiling step.
Is this possible, and if so, how would it be done?