Author Topic: ToUpper() vs StringComparison.InvariantCultureIgnoreCase  (Read 2586 times)

0 Members and 1 Guest are viewing this topic.

nobody

  • Swamp Rat
  • Posts: 861
  • .net stuff
ToUpper() vs StringComparison.InvariantCultureIgnoreCase
« on: June 21, 2016, 01:24:36 AM »
ToUpper() vs StringComparison.InvariantCultureIgnoreCase....was going through some old c# docs and just saw this... I use ToUpper() all the time as a lazy way to compare strings...but the document I was reading mentions using the string comparison instead... I can't think of why it would matter.... thoughts?

kdub_nz

  • Mesozoic keyThumper
  • SuperMod
  • Water Moccasin
  • Posts: 2122
  • class keyThumper<T>:ILazy<T>
Re: ToUpper() vs StringComparison.InvariantCultureIgnoreCase
« Reply #1 on: June 21, 2016, 01:54:50 AM »

Was that related to something like 'The Turkey Test ' ?
Called Kerry in my other life
Retired; but they dragged me back in !

I live at UTC + 13.00

---
some people complain about loading the dishwasher.
Sometimes the question is more important than the answer.

nobody

  • Swamp Rat
  • Posts: 861
  • .net stuff
Re: ToUpper() vs StringComparison.InvariantCultureIgnoreCase
« Reply #2 on: June 21, 2016, 02:03:15 AM »

Was that related to something like 'The Turkey Test ' ?

That's interesting... had to look it up...never heard of it before but makes for some good reading. Not sure if that's what the author referred to though. They simply said it's just better.

Andrey Bushman

  • Swamp Rat
  • Posts: 864
Re: ToUpper() vs StringComparison.InvariantCultureIgnoreCase
« Reply #3 on: June 22, 2016, 04:27:39 PM »
Note, that ToLower() is "better" than ToUpper() for comparring of strings  because some chars in some languages haven't upper variant.

nobody

  • Swamp Rat
  • Posts: 861
  • .net stuff
Re: ToUpper() vs StringComparison.InvariantCultureIgnoreCase
« Reply #4 on: June 25, 2016, 11:01:43 PM »
Note, that ToLower() is "better" than ToUpper() for comparring of strings  because some chars in some languages haven't upper variant.

Thanks Andrey! nice tip