Compile and run C# code from another program
I need to dynamically build and run a student’s code (StudentCode.cs
) from within my class (TeacherCode.cs
). I’m using reflection and Roslyn for this purpose. Specifically, I want to check if StudentCode.cs
contains a method named Print
, and if it does, I want to invoke this method. (Later on, I also want to check if the student uses recursion, loops, among other code constructs.)