c# executing code from string code example
Example: c# execute code from string
I managed to get a work around. I have resolved to Roslyn. Below is the code:
public class Globals
{
public InsuredItem _i;
public decimal SumAssured;
}
foreach (InsuredItem _i in p.InsuredItems)
{
string formula = "(_i.PremiumRate/100)*SumAssured";
var script = CSharpScript.Create<decimal>(formula, globalsType: typeof(Globals))
.CreateDelegate();
_i.Premium = await script(new Globals { _i = _i, SumAssured = SumAssured });
}