Skip to content

mustaddon/CSharpEval

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

CSharpEval NuGet version

Compile and execute C# code at program runtime

Examples

Simple math expression

var result = CSharpEval.Execute<int>("A + B", new { A = 2, B = 3});

Linq sample

var result = CSharpEval.Execute<int>(@"
    var list = new List<int>() { 1, 2, 3, 4, 5 };
    return list.Where(x => x < K).Sum(x => x);
", new { K = 5 });

Adding references

CSharpEval.Execute("Console.WriteLine(A)", 
    new { A = ExternalLib.SomeEnum.Sample }, 
    new[] { Assembly.GetAssembly(typeof(ExternalLib.SomeEnum)) });

About

Compile and execute C# code at program runtime

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages