0

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.

1 Answer 1

0

$"new TaskSolution().Calculate({input})" evaluates to "new TaskSolution().Calculate(System.Int32[])", which is not valid code. input would be treated as string, not passed as the actual array.

Sign up to request clarification or add additional context in comments.

1 Comment

Ooh, thank you. Your comment helped me to understand that I should use another way of implementation. stackoverflow.com/questions/38278701/… - one of these ways

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.