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

css - I want to align grid in center -

Contact Form PHP Email Script -

python - SWIG function not printing output -