Solved

Ability to make switch() statement case-insensitive?

Posted on 2006-11-22
2
1,280 Views
Last Modified: 2011-10-03
C#'s switch() statement is case-sensitive.  Is there a way to toggle it so it becomes case-insensitive?


-= DeathToSpam =-
0
Comment
Question by:deathtospam
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
2 Comments
 
LVL 23

Accepted Solution

by:
adathelad earned 500 total points
ID: 17997231
Hi,

Convert the string to "switch" on to lowercase (or uppercase if you prefer):
e.g.
switch (yourString.ToLower())
{
    case "somelowercasestring":
        // Do something
        break;

    case "anotherlowercasestring":
        // Do something else
        break;
}
0
 
LVL 23

Expert Comment

by:adathelad
ID: 17997243
Also just to add, it's not that C#'s switch statement is case-sensitive - more that C# as a whole is case-sensitive
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
The article shows the basic steps of integrating an HTML theme template into an ASP.NET MVC project
Michael from AdRem Software explains how to view the most utilized and worst performing nodes in your network, by accessing the Top Charts view in NetCrunch network monitor (https://www.adremsoft.com/). Top Charts is a view in which you can set seve…
If you’ve ever visited a web page and noticed a cool font that you really liked the look of, but couldn’t figure out which font it was so that you could use it for your own work, then this video is for you! In this Micro Tutorial, you'll learn yo…

695 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question