Linked Questions

4 votes
3 answers
18k views

C#'s switch statement is case-sensitive. Is there a way to toggle it so it becomes case-insensitive? [duplicate]

C#'s switch() statement is case-sensitive. Is there a way to toggle it so it becomes case-insensitive? ============================== Thanks, But , I don't like these solutions; Because case ...
xiemails's user avatar
  • 843
1 vote
3 answers
15k views

C# Switch statement [duplicate]

I'm new to programming i started to learn C# language Console.WriteLine("yes or no ?"); string answer = Console.ReadLine(); switch (answer) { case "yes":...
Kamal Hesham's user avatar
0 votes
3 answers
496 views

How to compare strings without case-sensitivity? [duplicate]

I'm writing a code where the user has to input if he wants a feature or not by pressing "y" or "n" or writting "yes" or "no", without checking for case-sensitivity (so it needs to work if the user ...
Thales Vilela's user avatar
1 vote
0 answers
125 views

Switch statement case block not recognizing expected string value [duplicate]

I have a very strange issue occurring within a switch statement in C# inside of VS2013. The switch statement evaluates a string value and has several cases expecting specific strings. Some of the ...
zanderwel's user avatar
  • 155
0 votes
0 answers
37 views

C# user input case-insensitive using switch [duplicate]

using System; namespace TakeHome { class Program { static void Main(string[] args) { Console.WriteLine("What is the opposite of black ?"); ...
Bliz's user avatar
  • 1
1472 votes
296 answers
762k views

Hidden Features of C#? [closed]

This came to my mind after I learned the following from this question: where T : struct We, C# developers, all know the basics of C#. I mean declarations, conditionals, loops, operators, etc. Some ...
151 votes
17 answers
127k views

C# switch statement limitations - why?

When writing a switch statement, there appears to be two limitations on what you can switch on in case statements. For example (and yes, I know, if you're doing this sort of thing it probably means ...
ljs's user avatar
  • 37.9k
93 votes
4 answers
29k views

What is wrong with ToLowerInvariant()?

I have the following line of code: var connectionString = configItems. Find(item => item.Name.ToLowerInvariant() == "connectionstring"); VS 2010 code analysis is telling me the ...
JL.'s user avatar
  • 81.7k
3 votes
4 answers
7k views

Compare strings in C# in switch-case block with different casing [closed]

I have a set of switch-case statements, such as "Hello, how are you", "Hi, how can I help you?". If the input from the user is verbatim i.e: "Hello, how are you", the ...
user1144596's user avatar
  • 2,098
6 votes
1 answer
7k views

Using Switch case with Equals method in C#

Is there a way to convert the below if else condition into Switch in C#. I am using Equals method for checking the type, but unable to convert to switch case. if (fi.FieldType.Equals(typeof(int))) { ...
Bhrathi's user avatar
  • 89
-1 votes
2 answers
163 views

Per-String function (IDK how it's called)

I'm working on my C# project, and I need to do this, but without the If, in a short way; for (String = n) do that for (String = s) do those for (String = c) do this I don't know how it's called, or ...
TDT-Alpha's user avatar
-1 votes
2 answers
114 views

Replacing IF and Else If statements from my method [duplicate]

I need some help if it is a way to the below. Scenario is that I have an incoming order on the backend machines. And before I can process it I need to do some stuff with the order before depending on ...
A Dumbledore's user avatar