Search
 
SCRIPT & CODE EXAMPLE
 

CSHARP

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();");
Comment

PREVIOUS NEXT
Code Example
Csharp :: all substrings of a string c# 
Csharp :: c# loop xml 
Csharp :: select random from enum c# 
Csharp :: compact in laravrl 
Csharp :: how to turn a string in a char list c# 
Csharp :: c# pi 
Csharp :: input field to float unity 
Csharp :: c# example code 
Csharp :: vb.net read text file line by line 
Csharp :: unity gameobject find inactive 
Csharp :: should i learn c # 
Csharp :: variable size in memory c# 
Csharp :: c# convert datetime to year & month 
Csharp :: c# add key value pair to dictionary 
Csharp :: c# arrow 
Csharp :: tostring format 2 decimals 
Csharp :: Convert Json String to model Class or Object 
Csharp :: Failed to generate swagger file. Error dotnet swagger tofile --serializeasv2 --output 
Csharp :: get quaternion from vector unity 
Csharp :: sieve of eratosthenes 
Csharp :: unity ui button 
Csharp :: Disable Debug.log Unity 
Csharp :: c# fileupload example 
Csharp :: c# find element in list of list 
Csharp :: Call Thread in C# 
Csharp :: Why Duplicate "..TargetFrameworkAttribute" c# assemblies created 
Csharp :: pubxml environment variables 
Csharp :: xamarin set environment variables 
Csharp :: c# external ip 
Csharp :: asp net c# browser cursor wait 
ADD CONTENT
Topic
Content
Source link
Name
7+2 =