|
-
Alternative to switch case
I'm sure this is a problem that almost everyone has dealt with:
Any suggestions on how to work a switch statement with a string?
I have a string array, where I want to base my switch on the first element.
The first element can have about 25+ different values. This makes using a hashcode a bit on the awkward side, since there will be no way to keep track of what each case is for. (Well placed comments would do it, but doesn't help much with making the code readable.)
Should I make an enum for all possible values and have a call to assign one for my switch. This seems like a bit of overkill.
Or is there something else that may work better?
Similar Threads
-
By Dark Rain in forum Java
Replies: 8
Last Post: 09-30-2005, 06:42 PM
-
By VanDam in forum Database
Replies: 0
Last Post: 07-09-2005, 04:18 AM
-
By Daryl Shockey in forum Database
Replies: 2
Last Post: 05-28-2002, 03:50 PM
-
By Martin in forum VB Classic
Replies: 22
Last Post: 12-03-2001, 03:53 AM
-
By Yoel Martinez in forum VB Classic
Replies: 1
Last Post: 12-12-2000, 03:17 PM
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
Forum Rules
|
Top DevX Stories
Easy Web Services with SQL Server 2005 HTTP Endpoints
JavaOne 2005: Java Platform Roadmap Focuses on Ease of Development, Sun Focuses on the "Free" in F.O.S.S.
Wed Yourself to UML with the Power of Associations
Microsoft to Add AJAX Capabilities to ASP.NET
IBM's Cloudscape Versus MySQL
|
Bookmarks