Most times I want to do string comparisons I want them to be case insensitive.
So why are string in .net case sensitive by default?
EDIT 1: To be clear I think the below should return true by default. Or at least allow me to have a compile time flag that makes it so.
"John Smith" == "JOHN SMITH"
EDIT 2: I can think of many more examples of things that should be case insensitive
Examples of things that should be case insensitive
- Usernames
- Urls
- File extensions / File names / Directory names / Paths
- Machine / servernames
- State / Country / Location etc
- FirstName / LastName / Initials
- Guids
- Month / Day names
Examples of things that should be case sensitive
- Passwords
Sorry for the trivial answer, but that’s just the way it is 🙂
At a basic level, strings are represented as a list of characters, where ‘a’ is different from ‘A’, so it’s probably the easiest representation \ convention overall. In your case, it’s probably fair to say that the majority of comparisons is case-insensitive, but I think the other side of the argument holds true at least as much and a convention has been adopted.
I’d imagine utilizing some helper methods \ classes would ease your pain somewhat.