Case insensitive compare of single characters

C

Coder Guy

Is it possible to do a case insensitive comparison of individual characters?
I tried:

Char.ToLowerInvariant(charA).CompareTo(Char.ToLowerInvariant(charB))

And though it works for the most part, it didn't seem to work for all
locales.

I tried converting the characters to a string and then do a case insensitive
comparison, and this always worked. Unfortunately this comparison is being
called millions of times and converting to a string is terribly inefficient.
Do I have any other options?

Thanks
 
C

Christof Nordiek

Coder Guy said:
Is it possible to do a case insensitive comparison of individual
characters? I tried:

Char.ToLowerInvariant(charA).CompareTo(Char.ToLowerInvariant(charB))

And though it works for the most part, it didn't seem to work for all
locales.

Can you say, where it doesn't work?

Since ToLowerInvariant aswell as CompareTo are culture invariant, the result
shouldn't depend on the locale

Christof
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top