0

I wonder if there is some method of executing a string, or convert it to a code, example: "Console.WriteLine (\" Hello \ ")";

Equivalent to 'eval' in JavaScript.

I've translated it from Translate Google.

Translate Google

3

4 Answers 4

2

It is a bit more contrived then using eval in some languages, but it is certainly possible to programmatically compile code.

Sign up to request clarification or add additional context in comments.

Comments

0

I wrote a tutorial on something very similar to this a few years ago - it is based on compiling though:

http://domscode.com/2011/02/16/new-tutorial-tdd-c-web-compiler/

Hope that helps

Comments

0

You can try cshell: http://cshell.net/

It has a repl-based and executes c# code.

Comments

0

I haven't tried it myself, but it seems what you're looking for is easily feasible using Roslyn ( .Net compiler service )
Take a look at eval()-like for C# using Roslyn and ScriptCS and Hosted Execution of smaller code snippets with Roslyn

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.