Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Execute the C# code in runtime
using Microsoft.CodeAnalysis.CSharp.Scripting;
using Microsoft.CodeAnalysis.Scripting;
using System;
namespace RuntimeCompile
internal class Program
private static void Main(string[] args)
var code = "(5 + 3).ToString()";
var run = CSharpScript.RunAsync(code, ScriptOptions.Default).Result;
var result = (string)run.ReturnValue;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment