Click here to Skip to main content
16,007,843 members
Home / Discussions / C#
   

C#

 
GeneralRe: Switch with Strings Pin
Matthew Butler10-Mar-08 13:44
Matthew Butler10-Mar-08 13:44 
GeneralRe: Switch with Strings Pin
Jammer10-Mar-08 13:48
Jammer10-Mar-08 13:48 
GeneralRe: Switch with Strings Pin
Matthew Butler10-Mar-08 14:06
Matthew Butler10-Mar-08 14:06 
GeneralRe: Switch with Strings Pin
Luc Pattyn10-Mar-08 14:14
sitebuilderLuc Pattyn10-Mar-08 14:14 
GeneralRe: Switch with Strings Pin
Matthew Butler10-Mar-08 14:19
Matthew Butler10-Mar-08 14:19 
GeneralRe: Switch with Strings Pin
darkelv10-Mar-08 14:00
darkelv10-Mar-08 14:00 
GeneralRe: Switch with Strings Pin
Jammer10-Mar-08 14:01
Jammer10-Mar-08 14:01 
GeneralRe: Switch with Strings Pin
Scott Dorman10-Mar-08 15:35
professionalScott Dorman10-Mar-08 15:35 
From your example, it looks like you've got the concept of a switch statement a bit backwards. The syntax is
C#
switch (boolean expression)
{
   case [expression result 1]:
      break;
}
That being said, the switch can't take two values like you have but it can take any expression that returns a boolean. For what you are trying to do, it would be easier to just use an if/else block.

When comparing strings you should also be careful about comparisons using the == operator as it may not always return the result you expect on all platforms/languages. It's better to use the comparison functions in the string class itself.

Scott.

—In just two days, tomorrow will be yesterday.
—Hey, hey, hey. Don't be mean. We don't have to be mean because, remember, no matter where you go, there you are. - Buckaroo Banzai

[Forum Guidelines] [Articles] [Blog]

GeneralRe: Switch with Strings Pin
Vikram A Punathambekar10-Mar-08 18:45
Vikram A Punathambekar10-Mar-08 18:45 
GeneralRe: Switch with Strings [modified] Pin
Scott Dorman11-Mar-08 2:50
professionalScott Dorman11-Mar-08 2:50 
GeneralRe: Switch with Strings Pin
Jammer11-Mar-08 9:15
Jammer11-Mar-08 9:15 
GeneralRe: Switch with Strings Pin
DaveyM6911-Mar-08 1:34
professionalDaveyM6911-Mar-08 1:34 
QuestionCOM Interop, COM+, C++ Unmanaged, C# .NET 2.0 Class Library->C# .NET 1.1 Class Library Pin
scottdj10-Mar-08 13:16
scottdj10-Mar-08 13:16 
GeneralRe: COM Interop, COM+, C++ Unmanaged, C# .NET 2.0 Class Library->C# .NET 1.1 Class Library Pin
Scott Dorman10-Mar-08 15:37
professionalScott Dorman10-Mar-08 15:37 
QuestionHow to do print in c#? Pin
Dong Kim10-Mar-08 12:31
Dong Kim10-Mar-08 12:31 
GeneralRe: How to do print in c#? Pin
Xmen Real 10-Mar-08 16:21
professional Xmen Real 10-Mar-08 16:21 
Generalform multithreading trouble!... Pin
Gilly Barr10-Mar-08 11:58
Gilly Barr10-Mar-08 11:58 
GeneralRe: form multithreading trouble!... Pin
Gareth H10-Mar-08 12:20
Gareth H10-Mar-08 12:20 
Generalnew Form/thread to remain open after main Application closes Pin
Alex4thDegree10-Mar-08 9:53
Alex4thDegree10-Mar-08 9:53 
GeneralRe: new Form/thread to remain open after main Application closes Pin
led mike10-Mar-08 10:04
led mike10-Mar-08 10:04 
GeneralRe: new Form/thread to remain open after main Application closes Pin
Alex4thDegree10-Mar-08 10:24
Alex4thDegree10-Mar-08 10:24 
GeneralRe: new Form/thread to remain open after main Application closes Pin
Christian Graus10-Mar-08 10:21
protectorChristian Graus10-Mar-08 10:21 
GeneralRe: new Form/thread to remain open after main Application closes Pin
Alex4thDegree10-Mar-08 10:26
Alex4thDegree10-Mar-08 10:26 
GeneralRe: new Form/thread to remain open after main Application closes Pin
led mike10-Mar-08 11:17
led mike10-Mar-08 11:17 
GeneralRe: new Form/thread to remain open after main Application closes Pin
Alex4thDegree11-Mar-08 3:58
Alex4thDegree11-Mar-08 3:58 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.