I need to display a certain number on a label when the user input is between >=0 and <= 1. User input is a string and I need the numbers between to be a decimal or double. Obviously I can't compare the two like I did because the operators can't compare a string and decimal, double, or int.
private void voltageTextBox_TextChanged(object sender, EventArgs e)
{
var RTPower = powerTextBox.Text;
powerTextBox.CharacterCasing = CharacterCasing.Upper;
if (RTPower >= 0 && <= 1)
{
displayLabel4.Text = "1";
}
}
Error: Operator '>=' cannot be applied to operands of type 'string' and 'int'
Error: Operator '<=' cannot be applied to operands of type 'string' and 'int'
How can I make that if statement work? Do I have to keep it as a string, display it in label, convert the label to an integer then re-display it? I know I can make that work, but that is far too complicated. I just need an easier way to do this.