Solved

Ability to make switch() statement case-insensitive?

Posted on 2006-11-22
2
1,263 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
  • 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

How to improve team productivity

Quip adds documents, spreadsheets, and tasklists to your Slack experience
- Elevate ideas to Quip docs
- Share Quip docs in Slack
- Get notified of changes to your docs
- Available on iOS/Android/Desktop/Web
- Online/Offline

Join & Write a Comment

Suggested Solutions

Article by: Najam
Having new technologies does not mean they will completely replace old components.  Recently I had to create WCF that will be called by VB6 component.  Here I will describe what steps one should follow while doing so, please feel free to post any qu…
Entity Framework is a powerful tool to help you interact with the DataBase but still doesn't help much when we have a Stored Procedure that returns more than one resultset. The solution takes some of out-of-the-box thinking; read on!
This video shows how to remove a single email address from the Outlook 2010 Auto Suggestion memory. NOTE: For Outlook 2016 and 2013 perform the exact same steps. Open a new email: Click the New email button in Outlook. Start typing the address: …
This video demonstrates how to create an example email signature rule for a department in a company using CodeTwo Exchange Rules. The signature will be inserted beneath users' latest emails in conversations and will be displayed in users' Sent Items…

760 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

Need Help in Real-Time?

Connect with top rated Experts

22 Experts available now in Live!

Get 1:1 Help Now