Skip to content

OperatorConverter.ToValue(string)

Yi Zhang edited this page May 29, 2018 · 1 revision

Namespace: ConverterClassLibrary

Description: Maps an operator to numeric value.

Parameters Description
token<string> operator to convert
Returns Description
int non-negative values for valid operators, -1 otherwise

Examples:

string[] operators = { "+", "-", "!" };
var converter = new OperatorConverter(operators, null);

Console.WriteLine(converter.ToValue("+")); //0
Console.WriteLine(converter.ToValue("-")); //1
Console.WriteLine(converter.ToValue("!")); //2
Console.WriteLine(converter.ToValue("%")); //-1

Clone this wiki locally