Why won't ExpressionEvaluator work with variables?

In my game, I wanted a string of equation objects (e.g. 1, +, 5, etc.) to be calculated into an answer. For example, the string “4 + 5” should produce the result 9. The numbers and operations change throughout the game. I found this function named ExpressionEvaluator, and thought it would work by placing the string variable like this:

public int output;
private string calcsString;

void Update()
{
    output = ExpressionEvaluator.Evaluate<int>(calcsString); 
}

However, Unity kept on returning me this error:

error CS0305: Using the generic type 'List<T>' requires 1 type arguments

What am I doing wrong here?

Well, there’s a lot wrong here. First of all the error you showed is completely unrelated to the code you showed.

Second the class ExpressionEvaluator is an editor class and therefore can not be used by your game, only by editor scripts.

In your title you mention variables but in your description it looks like you have expressions with just literal values.

If you need an expression evaluator solution that works at runtime you can use my LogicExpressionParser which is an improved version of by old ExpressionParser. It’s a very simply straight forward implementation. Though they support variables and custom functions. The created expression tree can be re-evaluated later when the variables have changed. Variables can be introduced as closures of actual C# variables.