Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
C# syntax question: switch and IndexOf
Message
General information
Forum:
ASP.NET
Category:
Coding, syntax and commands
Environment versions
Environment:
C# 1.1
OS:
Windows XP SP2
Network:
Windows 2000 Server
Database:
MS SQL Server
Miscellaneous
Thread ID:
01010821
Message ID:
01010835
Views:
16
>While I'm sure someone can come up with a way to do this with a switch construct, you may just want to use if/else which can function much more like VFP's DO CASE:
>
>if (check for match 1)
>{
>  routine 1 or call routine 1 here;
>}
>else if (check for match 2)
>{
>  routine 2 or call routine 2 here;
>}
>...
>else if (check for match 11)
>{
>  routine 11 or call routine 11 here;
>}
>else
>{
>  invalid file type encountered;
>}
>
>And you could also have a method that takes an int or string that coincides with the file types and use the switch construct there and just call that method from the above code.



Chad

Yes. This is what I'm doing now. After typing the message, it became clearer that a simple nested if or elseif would do aso I went with it for starters, but I'm looking for something more graceful. Thanks for the input.


Alex Feldstein, MCP, Microsoft MVP
VFP Tips: English - Spanish
Website - Blog - Photo Gallery


"Once again, we come to the Holiday Season, a deeply religious time that each of us observes, in his own way, by going to the mall of his choice." -- Dave Barry
Previous
Reply
Map
View

Click here to load this message in the networking platform