winforms - The statement if combobox selectedindex == 1 || 2 gives a syntax error in c# -


i'm making human animal year converter.

my code:

if (combobox2.selectedindex == 1 || 2) {    combobox3.visible = true; }  

i following error :

operator '||' cannot applied operands of type 'bool' , 'int'

you can't use above expression

if (combobox2.selectedindex == 1 || 2) {    combobox3.visible = true; } 

you have use in following way:

if (combobox2.selectedindex == 1 || combobox2.selectedindex == 2 ) {    combobox3.visible = true; }  

Comments

Popular posts from this blog

user interface - How to replace the Python logo in a Tkinter-based Python GUI app? -

android - Get AccessToken using signpost OAuth without opening a browser (Two legged Oauth) -

org.mockito.exceptions.misusing.InvalidUseOfMatchersException: mockito -