An open API service indexing awesome lists of open source software.

https://github.com/mustaddon/csharpeval

Compile and execute C# code at program runtime
https://github.com/mustaddon/csharpeval

Last synced: 10 months ago
JSON representation

Compile and execute C# code at program runtime

Awesome Lists containing this project

README

          

# CSharpEval [![NuGet version](https://badge.fury.io/nu/RandomSolutions.CSharpEval.svg)](http://badge.fury.io/nu/RandomSolutions.CSharpEval)
Compile and execute C# code at program runtime

## Examples

*Simple math expression*
```csharp
var result = CSharpEval.Execute("A + B", new { A = 2, B = 3});
```

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

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