C# declare variable into if statement -
C# declare variable into if statement -
i want using c# :
if (i == 0) { button = new button(); } else { textblock = new textblock(); } mainpage.children.add(a); but error
error 1 name 'a' not exist in current context
any ideas ?
thank in advance !
you need mutual base of operations class both button , textblock derive from, , needs declared outside of if statement if it's accessed after if complete. control maybe?
control a; if (i == 0) { = new button(); } else { = new textblock(); } mainpage.children.add(a); not knowing specific command toolkit you're using (wpf maybe?) can't advise further. i'd @ signature add clue - what's parameter declared as?
c# variables if-statement
Comments
Post a Comment