dimanche 4 décembre 2022

Pass array as input parameter in CSharpScript

I try to run method by CSharpScript.

Method:

public class TaskSolution 
{ 
   public int[] Calculate(int[] inputValue) 
   {
      return inputValue;
   }
}

I tried this solution:

var script = CSharpScript.Create(solution.Code);
var input = new int[3] { 1, 2, 3 };
var call = await script.ContinueWith<int[]>($"new TaskSolution().Calculate({input})").RunAsync();

But it throws Microsoft.CodeAnalysis.Scripting.CompilationErrorException with text "(1,43): error CS0443: Syntax error; value expected" and no more information inside.

When I run similar method but with simple input parameter (as int or string) - it runs successfully. But I meet problems with using arrays.





Aucun commentaire:

Enregistrer un commentaire