I am learning C# (in Visual Studio Express 2013 for Windows Desktop) by converting a simple Windows Form application I previously wrote in Visual Basic.
The following code sends a text box entry and two integers to a method that returns a boolean, but throws an exception at runtime whenever the text box doesn't contain an integer (e.g 155 is OK, but 155.67 isn't).
if (!(rangeOK(int.Parse(cmTextBox.Text), 50, 250))) return false;
I've tried using TryParse to resolve this, but despite trying lots of online tips (and others' questions in here) I haven't been able to understand how I should do it.
If it helps the original VB code was:
If Not (rangeOK(Val(cmTextBox.Text), 50, 250)) Then Return False
Many thanks
Rob