i'm trying to create a simple natural language calculate. this is what i am trying to achieve, If i input the string "five plus six" the output should be answer: 11.
below i tried to create a Enum of numbers but for operators it does not accept strings,i use this so i can fetch and compare to the array input and covert respectively,could you please suggest what i can maybe use to store operators as words so? or suggest an article maybe.
code:
public class EnumSample
{
enum Numbers: int
{
zero = 0,
obne = 1,
two = 2,
three =3,
four =4,
five =5,
six =6,
seven=7,
eight = 8,
nine=9,
};
enum Operator
{
Add = "+",
plus ="+",
minus ="-",
subtract ="-"
};
public static void Main()
{
int[] arr = new int[200];
Console.Write("Get input");
for (int i = 0; i < 200; i++)
{
Console.Write("element - {0} : ", i);
arr[i] = Convert.ToInt32(Console.ReadLine());
}
foreach (int item in Enum.GetValues(typeof (Numbers)))
{
String name = Enum.GetName(typeof(Numbers), item);
Console.WriteLine(name+item);
}
Console.Read();
}
}