if-else vs switch
If you switch on a numeric value, the value is used as an index in a table containing the address of the next instruction to execute. If the case values are not close to each other, the ranges of...
View Articleif-else vs switch
On a different note after all these discussion, I got a curiosity to know what is the basic difference between if-else and switch statements. I do know when to use if-else and when switch statements....
View Articleif-else vs switch
Hi,In ADA language, for instance, we can evaluate the condition in the case statement : type Digit is new Integer range 0 .. 9; n : Digit; ... case n is when 0 => Put_Line ("You typed zero"); when 1...
View Articleif-else vs switch
I'd say that the problem you're talking about is due to the fact that the C# switch statement is strong, very strong. It's much more efficient than a series of if-else statements. And that's what is...
View Articleif-else vs switch
I'd say that the problem you're talking about is due to the fact that the C# switch statement is strong, very strong. It's much more efficient than a series of if-else statements. And that's what is...
View Articleif-else vs switch
Asalam-0-Alaikum 2 All{string line;if(line.Contains("import")){//Some Code Here}if(line.Contains("//")){//Neglect that Line as they are single line comments.}}My Question is that how can i change the...
View Articleif-else vs switch
Hi,Thanks for your post.When I saw this thread, I remembered a sentence on mirror of some automobiles: "OPJECTS ARE CLOSER THAN THEY APPEAR IN THE MIRROR" :)namespace ConsoleApplication2 { class...
View Articleif-else vs switch
I am assuming you're using this to do something like illustrate parsing command line parameters. byte a; a = (line.Contains("import") << 7); a = a | (line.Contains("\\") << 6); a = a |...
View Articleif-else vs switch
OK here is perhaps another way to do this, a lookup table. The code borrows from Mikes code above in that it produces a CodeType that is then used within a case statement. This approach still has the...
View Articleif-else vs switch
I agree with Derek and you that my way is much less readable. The original code is much better at self documenting. -- Mike
View Articleif-else vs switch
How about: // a type for the line type... public enum enumCodeType { Comment, Import, Code } // a method to return the line type by examination... enumCodeType ExamineLine(string line)...
View Articleif-else vs switch
Ingenious!But its seems easier to read the other way. :-)www.insteptech.com ; msmvps.com/blogs/deborahk We are volunteers and ask only that if we are able to help you, that you mark our reply as your...
View Articleif-else vs switch
How about: // a type for the line type... public enum enumCodeType { Comment, Import, Code } // a method to return the line type by examination... enumCodeType ExamineLine(string line)...
View Articleif-else vs switch
Not sure if you would consider this "proper and complete", but I don't think you can change your code to a switch case.For a switch statement to work, you have to have one specific value and then the...
View Articleif-else vs switch
Asalam-0-Alaikum 2 All{string line;if(line.Contains("import")){//Some Code Here}if(line.Contains("//")){//Neglect that Line as they are single line comments.}}My Question is that how can i change the...
View Article