home hardware prices news articles forums photos user reviews
Go Back   Tech Support Forums - TechIMO.com > PC Hardware and Tech > Webmastering and Programming
Ask a Tech Support Question (free)!

The annoying thing about C#.....

Reply
Get bargains at  »  Dealighted.com
 
Thread Tools Search this Thread
Currently Active Users: 2897
Discussions: 200,967, Posts: 2,379,679, Members: 246,333
Old October 1st, 2002, 03:39 AM   Digg it!   #1 (permalink)
Member
 
Join Date: Sep 2002
Posts: 364
The annoying thing about C#.....

Is I don't think there is a way to use a switch statement with a non explicit value. Meaning you can't have a case < 10. Has to be 10, or 20, or a string, or char or whatever.

If there is a way I can't find it anywhere. Can you still use case < 10 in VB.Net?
Creosote is offline   Reply With Quote
Old October 1st, 2002, 03:47 AM     #2 (permalink)
Not Really a Member
 
Join Date: Oct 2001
Posts: 25,395
errmm... why can't you
that's just retarded

guess you could put...
case 1
case 2
case 3
case 4
....
case 10
do something
lol

if you try it, it fails on compile?!?!
__________________
Helicopters don't fly; they vibrate so much and make so much noise that the earth rejects them.
vass0922 is online now   Reply With Quote
Old October 1st, 2002, 03:57 AM     #3 (permalink)
Member
 
Join Date: Sep 2002
Posts: 364
Yeah but even case 1, case 2, would be longer than nested if's because I go up to 85.

Underlines it in red as soon as I go "case < 10".
Creosote is offline   Reply With Quote
Old October 1st, 2002, 04:10 AM     #4 (permalink)
Not Really a Member
 
Join Date: Oct 2001
Posts: 25,395
yeah I tried it over here too
*mental note, C# sucks* lol
yeah I did some poking around, a lot of people seem to be bashing the INeffectiveness of C#'s switch statement...
looks like some nasty long elseif statements
Also saw you HAVE to put in break statements or GOTO (LOL) statements after every case ... ptttht
I'm gonna start learning C++ again.. staying away from C#
vass0922 is online now   Reply With Quote
Old October 1st, 2002, 04:15 AM     #5 (permalink)
Member
 
Join Date: Sep 2002
Posts: 364
Yeah, it took me a while to figure out about the breaks needing to be put in there. Overall, C# seems a lot easier than C++, at least for RAD. But I've had very minor C++ exposure.
Creosote is offline   Reply With Quote
Old October 1st, 2002, 01:19 PM     #6 (permalink)
Member
 
Join Date: Feb 2002
Posts: 161
Re: The annoying thing about C#.....

The same restrictions apply to switch statements in C, C++, and Java (and probably a few other languages). I imagine that it would be more difficult for the compiler to optimize ranged value comparisons, while a series of literal value comparisons can be compiled directly to a jump table.
Martee is offline   Reply With Quote
Old October 1st, 2002, 09:30 PM     #7 (permalink)
Member
 
Join Date: Sep 2002
Posts: 364
You don't have to break after every case in Java. Although you should anyways, but sometimes I'm lazy

You might think that this would be a feature MS would have implemented, however, since VB had it, and C# was made to be more RADish than C++.
Creosote is offline   Reply With Quote
Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Most Active Discussions
Is It Just Me? (3027)
Forty-six years ago today (12)
The disrespect of Obama by Russian .. (46)
Laptop with wireless problem. (12)
Wireless Televisions. (12)
CPU fan stops spinning randomly (11)
Regular Build (11)
Internet Lost (5)
windows vista security holes (16)
windows 7 problem (7)
Is the PSU I received dead? (13)
Point and Shoot Camera Suggestions. (6)
radeon x850xt platinum & shader.. (6)
HIS HD5770 graphic card question (15)
Recent Discussions
Browsers wont load websites (3)
Nvidia GTX 260 problem (2)
windows vista security holes (16)
Delete an OS (8)
help me pls laptop just stopped worki.. (0)
Open With ..... Win7 (3)
Help getting around port 80 for camer.. (4)
Laptop with wireless problem. (12)
Internet Lost (5)
Skillsoft Network+ Study Software Que.. (9)
virus blocking exe. files (1)
Point and Shoot Camera Suggestions. (6)
CPU fan stops spinning randomly (11)
Modern Warfare 2: Who Bought It? (65)
Is the PSU I received dead? (13)
Print spooler problem (16)
Kingston Bluetooth Dongle Driver (1)
Multiple Restarts Required at Boot (3)
webcam (0)
upgrade for hp a6101 (0)
tv not turn on-makes clicking sound (2)
EVGA 9800 gtx help with finding a goo.. (11)
Regular Build (11)
Help with onclick and buttons (0)
Virus advise (8)


All times are GMT -4. The time now is 04:27 PM.
TechIMO Copyright 2009 All Enthusiast, Inc.



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28