How to use math operators with strings? [duplicate]

int RTPower = Int32.Parse(powerTextBox.Text);

or for decimal values

decimal RTPower = Decimal.Parse(powerTextBox.Text);

You need to convert the value from a string to an int.

Also, I assume you are new to c# – my advice would be to avoid using var and explicitly declare your variables. It will make things clear and easier for you to learn and understand.

Leave a Comment