Hacker News new | ask | show | jobs
by shultays 406 days ago

  const string input = "interesting";
  bool comparison = input.ToUpper() == "INTERESTING";
  Console.WriteLine("These things are equal: " + comparison);
  Console.ReadLine();
Is this a realistic scenario? Changing case of a string and comparing it to something else? Running some kind of operations & logic on a string that is meant for user?

If you are doing such things then it looks more like a code smell.

3 comments

One use case I can think of: email string normalization during login. If your string localization is wrong, simple things like login can fail.

Edit: another use case: full text case insensitive searching of documents

Case insensitivity is a code smell?
as the other commenter says - normalization

right now I'm tinkering an old game that transforms all text inputs to uppercase ascii