0

I am curious as to if this is even possible. Is it possible to create a c# exe project with a rich text box that if I typed in for example

public void TestFunction(){
    MessageBox.Show("test");
};

that it would execute the code and build the function? I don't know if this makes sense. It was just one of those little questions that I had today and I don't know where to find the answer or what it is even called.

jkw4703
  • 332
  • 3
  • 16
  • 1
    http://stackoverflow.com/questions/826398/is-it-possible-to-dynamically-compile-and-execute-c-sharp-code-fragments :):) – User 12345678 Apr 10 '13 at 17:27
  • 1
    @ByteBlast Confused why you linked to exactly the same question I did, seven minutes later... O_o – cdhowie Apr 10 '13 at 17:30
  • That's what I was looking for! I just didn't know what to call it in order to find it. Thanks Guys! – jkw4703 Apr 10 '13 at 17:30

3 Answers3

1

ofc. it possible. See Reflection.Emit namespace

Dzmitry Martavoi
  • 6,657
  • 5
  • 37
  • 54
0

So basically you want to write an interpreter and compiler.

Yeah those sort of things exist, that's how your code works.

Otherwise there are the Reflection classes built into C# which might work for some small stuff.

Haedrian
  • 4,220
  • 2
  • 35
  • 53
0

Certainly possible using reflection but it is a lot of hard work...

Z.D.
  • 12,393
  • 1
  • 32
  • 54