Re: If statements inside switch statements?

  • From: Tyler Littlefield <tyler@xxxxxxxxxxxxx>
  • To: programmingblind@xxxxxxxxxxxxx
  • Date: Mon, 26 Jul 2010 12:20:46 -0600

if (bla)
{
//do something here!
}
else
{
//do something else here!
}

                Thanks,
Tyler Littlefield
        http://tds-solutions.net
        Twitter: sorressean

On Jul 26, 2010, at 11:55 AM, Jes wrote:

> 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
> 

__________
View the list's information and change your settings at
//www.freelists.org/list/programmingblind

Other related posts: