Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > Odd issue with Switch-Case statement in Code behind page.

Reply
Thread Tools

Odd issue with Switch-Case statement in Code behind page.

 
 
Guy Noir
Guest
Posts: n/a
 
      11-02-2006
Hello again. I'm assuming I'm doing something dumb here....

When I try and add a default: case to my switch statement, I get an
error that says "Error 1 Syntax error, '(' expected" and the red
squiggly is under the : after the word default. Can anyone see my silly
error? Thanks for the extra set of eyes!

-Guy

Here is the code for the entire method:

protected int[] GenerateClassfulSubnetMask(IPClasses ipClass)
{
switch (ipClass)
{
case IPClasses.ClassA:
int[] subnetMask = { 255, 0, 0, 0 };
return subnetMask;
case IPClasses.ClassB:
int[] subnetMask = { 255, 255, 0, 0 };
return subnetMask;
case IPClasses.ClassC:
int[] subnetMask = { 255, 255, 255, 0 };
return subnetMask;
case default:
break;
}
// If we reach here, something went wrong.....
int[] subnetMask = { 0, 0, 0, 0 };
return subnetMask;
}

 
Reply With Quote
 
 
 
 
Chris Fulstow
Guest
Posts: n/a
 
      11-02-2006
You just need to put "default:" rather than "case default:"

More info here:
http://msdn2.microsoft.com/en-US/library/06tc147t.aspx

--
Chris Fulstow
MCP, MCTS
http://chrisfulstow.blogspot.com/

 
Reply With Quote
 
 
 
 
Guy Noir
Guest
Posts: n/a
 
      11-02-2006
*DOH* thanks chris. I knew it was something stoopid.


Chris Fulstow wrote:
> You just need to put "default:" rather than "case default:"
>
> More info here:
> http://msdn2.microsoft.com/en-US/library/06tc147t.aspx
>
> --
> Chris Fulstow
> MCP, MCTS
> http://chrisfulstow.blogspot.com/


 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Non-code behind to code behind John ASP .Net 2 02-19-2007 07:08 PM
Odd behavior with odd code Michael Speer C Programming 33 02-18-2007 07:31 AM
Code-Behind Pain in the Behind! Daniel Manes ASP .Net 11 06-10-2005 09:47 PM
Code Behind and IF statement on whether to display content igloogod ASP .Net 1 01-22-2004 10:25 PM
Re: Code Behind vs. no code behind: error Ben Miller [msft] ASP .Net 1 06-28-2003 01:46 AM



Advertisments