I want to use the CalcEngine library for doing mathematic calculations in textboxes. The following codes are a part of the whole project. Why is it giving an error? The error is in CE.Evaluate(textBoxTLA.Text).ToString(). The error says:
Argument 2 should be passed by out keyword.
private void button1_Click(object sender, EventArgs e)
{
CalcEngine.CalcEngine CE = new CalcEngine.CalcEngine();
int.TryParse(textBoxTLA.Text, CE.Evaluate(textBoxTLA.Text).ToString());
}
TryParsetakes an integer as a second parameter, and you are supplying aString.It works like this (I don't know which string you want parsed, I assumed the evaluated one):
It is better to use
Parsethough, so you can do correct error handling (plus the code will be more readable).Also, you are doing a lot in one line, which makes it harder to debug, and to give clear messages to your user. For example, what if
CE.Evaluatefails?