Hi, What is the actual line of code that makes the compiler complain? Cheers, Joseph -----Original Message----- From: programmingblind-bounce@xxxxxxxxxxxxx [mailto:programmingblind-bounce@xxxxxxxxxxxxx] On Behalf Of Jes Sent: Monday, July 26, 2010 10:55 AM To: programmingblind@xxxxxxxxxxxxx Subject: Re: If statements inside switch statements? Exactly. Every time I type that, I always get, illegal, else without matching if. I am using Microsoft visual studio 2008 express edition Jes On Jul 26, 2010, at 12:24 PM, Chris Hofstader wrote: > Are you saying that you type something like: > > if( foo == bar) > doSomething(); > else > DoSomethingElse(); > > and the else doesn't work? > > On 07/26/2010 12:19 PM, Jes wrote: >> Sorry, let me clarify. The reason I use switch is because I can't get else statements to work inside your regular if then statements. >> if (some condition happens) >> { >> Do this >> } >> else >> { >> do this other thing >> } //end if >> I can't get the else, portion of my code to compile. >> That's why I use switch. >> So, if I needed to put an if, then, statement inside of switch, is that good programming practice? >> Thanks >> Jes >> >> __________ >> View the list's information and change your settings at >> //www.freelists.org/list/programmingblind >> >> > __________ > View the list's information and change your settings at //www.freelists.org/list/programmingblind > __________ View the list's information and change your settings at //www.freelists.org/list/programmingblind No virus found in this incoming message. Checked by AVG - www.avg.com Version: 8.5.441 / Virus Database: 271.1.1/3029 - Release Date: 07/26/10 06:36:00 __________ View the list's information and change your settings at //www.freelists.org/list/programmingblind