Operator <= cannot be applied to operands of type ' String' and 'int' | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1

Operator <= cannot be applied to operands of type ' String' and 'int'

Hi I'm not really good in coding because I'm kinda noob. Can you guys help me? I'm getting this error and can yall fix it? String txtQty = "" ; Int y = 15; If (txtQty < = y) { Message Box. Show("Inventory is low") ; }

22nd Jun 2019, 6:08 AM
AB Rizni
AB Rizni - avatar
6 Answers
+ 1
You should not use spaces between < and =. Valid: <= Invalid: < =
22nd Jun 2019, 6:10 AM
Seb TheS
Seb TheS - avatar
+ 1
Sorry, I almost somehow thought you were using JavaScript. But it seems that C theSharpOne, doesn't support comparing strings and integers. That's okay, because it would rarely give any sensible results, even in the programming languages it worked.
22nd Jun 2019, 6:20 AM
Seb TheS
Seb TheS - avatar
+ 1
Maybe you can transform the string txtQty to integer somehow.
22nd Jun 2019, 6:25 AM
Seb TheS
Seb TheS - avatar
+ 1
Ok I will try that , thanks
22nd Jun 2019, 9:44 AM
AB Rizni
AB Rizni - avatar
0
Seb TheS I tried that but same error 😔
22nd Jun 2019, 6:13 AM
AB Rizni
AB Rizni - avatar
0
So what should I do to correct it?
22nd Jun 2019, 6:22 AM
AB Rizni
AB Rizni - avatar