Horje
how to evaluate code in c# Code Example
how to evaluate code in c#
//Unfortanatly you cant because c# isnt a Dynamic language
//but you can use the Roslyn scripting API
// add NuGet package 'Microsoft.CodeAnalysis.Scripting'
using Microsoft.CodeAnalysis.CSharp.Scripting;

await CSharpScript.EvaluateAsync("System.Math.Pow(2, 4)") // returns 16
//You can also run any piece of code:
var script = await CSharpScript.RunAsync(@"
               class MyClass
               { 
                   public void Print() => System.Console.WriteLine(1);
               }");
//And reference the code that was generated in previous runs:
await script.ContinueWithAsync("new MyClass().Print();");




Csharp

Related
c# loop array Code Example c# loop array Code Example
c# multiple exceptions same handler Code Example c# multiple exceptions same handler Code Example
by value by reference c# Code Example by value by reference c# Code Example
pointer in c# Code Example pointer in c# Code Example
c# list item not in another list Code Example c# list item not in another list Code Example

Type:
Code Example
Category:
Coding
Sub Category:
Code Example
Uploaded by:
Admin
Views:
11