Click here to Skip to main content
15,885,278 members
Home / Discussions / C#
   

C#

 
Questionelse if statement vs switch statement Pin
DeAd_HeAd21-Oct-12 12:18
DeAd_HeAd21-Oct-12 12:18 
AnswerRe: else if statement vs switch statement Pin
Richard Andrew x6421-Oct-12 14:52
professionalRichard Andrew x6421-Oct-12 14:52 
GeneralRe: else if statement vs switch statement Pin
DeAd_HeAd21-Oct-12 16:07
DeAd_HeAd21-Oct-12 16:07 
GeneralRe: else if statement vs switch statement Pin
Richard Andrew x6421-Oct-12 16:17
professionalRichard Andrew x6421-Oct-12 16:17 
GeneralRe: else if statement vs switch statement Pin
Richard Deeming22-Oct-12 2:05
mveRichard Deeming22-Oct-12 2:05 
JokeRe: else if statement vs switch statement Pin
BobJanova22-Oct-12 4:24
BobJanova22-Oct-12 4:24 
AnswerRe: else if statement vs switch statement Pin
Abhinav S21-Oct-12 17:47
Abhinav S21-Oct-12 17:47 
AnswerRe: else if statement vs switch statement Pin
Kevin Bewley21-Oct-12 23:34
Kevin Bewley21-Oct-12 23:34 
As others have said, it has to be if-else or rethink your tests and perhaps do a pre-assignment to get a switch-case statement.

With really complex if-else cascades one trick I like to use is to make a pre-defined array (think of it as a decision table). This means that the code is much simpler to read and also, changing your logic only means updating the decision table.

I don't know if it's considered 'good programming practise' as I'm not a Pro, just a hobby coder. But, it works for me.
GeneralRe: else if statement vs switch statement Pin
BobJanova22-Oct-12 4:24
BobJanova22-Oct-12 4:24 
Questionparameter comments for a method wont work fine Pin
mohammadkaab21-Oct-12 8:28
mohammadkaab21-Oct-12 8:28 
AnswerRe: parameter comments for a method wont work fine Pin
Eddy Vluggen21-Oct-12 22:17
professionalEddy Vluggen21-Oct-12 22:17 
GeneralRe: parameter comments for a method wont work fine Pin
mohammadkaab22-Oct-12 0:34
mohammadkaab22-Oct-12 0:34 
GeneralRe: parameter comments for a method wont work fine Pin
Eddy Vluggen22-Oct-12 0:52
professionalEddy Vluggen22-Oct-12 0:52 
Questionwhat does this error mean? Pin
Member 939900720-Oct-12 18:33
Member 939900720-Oct-12 18:33 
AnswerRe: what does this error mean? Pin
Brisingr Aerowing20-Oct-12 19:16
professionalBrisingr Aerowing20-Oct-12 19:16 
Questionhow I can make the intranet developed in c # to connect to several database in SQL Server 2008 R2 Pin
jaime durand20-Oct-12 18:28
professionaljaime durand20-Oct-12 18:28 
AnswerRe: how I can make the intranet developed in c # to connect to several database in SQL Server 2008 R2 Pin
uspatel20-Oct-12 19:03
professionaluspatel20-Oct-12 19:03 
AnswerRe: how I can make the intranet developed in c # to connect to several database in SQL Server 2008 R2 Pin
Mycroft Holmes21-Oct-12 16:16
professionalMycroft Holmes21-Oct-12 16:16 
Questionerror "object reference not set to an instance of an object" c# Pin
madimboo20-Oct-12 12:30
madimboo20-Oct-12 12:30 
AnswerRe: error "object reference not set to an instance of an object" c# Pin
Richard Andrew x6420-Oct-12 13:48
professionalRichard Andrew x6420-Oct-12 13:48 
AnswerRe: error "object reference not set to an instance of an object" c# Pin
Dave Kreskowiak20-Oct-12 20:48
mveDave Kreskowiak20-Oct-12 20:48 
AnswerRe: error "object reference not set to an instance of an object" c# Pin
Eddy Vluggen21-Oct-12 0:32
professionalEddy Vluggen21-Oct-12 0:32 
AnswerRe: error "object reference not set to an instance of an object" c# Pin
Abhinav S21-Oct-12 17:47
Abhinav S21-Oct-12 17:47 
QuestionChatting application in C# Pin
speedchandu20-Oct-12 11:27
speedchandu20-Oct-12 11:27 
AnswerRe: Chatting application in C# Pin
Richard Andrew x6420-Oct-12 13:49
professionalRichard Andrew x6420-Oct-12 13:49 

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.