Hi everyone!
Is it possible to change the body of method during runtime?
class Person
{
public void DoSth()
{ Console.WriteLine("Hello!"); }
}
I wanted to have a simple input field (like a textbox) where I can write the method body source code during runtime.
The textbox may contain data like:
for (int i = 0; i < 5; i++)
Console.WriteLine(i);
which should be excecuted when
new Person().DoSth()
is called.
Is (or how is) this possible in C# (using Reflection)?
Thanks for your help in advance.
EDIT:
If the above isn't possible, is it possible to create a new method during runtime and call it?