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

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

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

google shop client API returns 400 bad request error while adding an item -