How to compare strings at C# like in SQL server case insensitive and accent insensitive

1.5k Views Asked by At

Alright here 4 words which are equal at SQL server Latin1_General_100_CI_AI collation which is case insensitive and accent insensitive

taraflı
TaraFLI
TARaFLİ
Tarafli

However i could not find a way to compare these as equal at C# .net 4.5.1

Are there any way to make such comparsion like in SQL server ?

I checked this thread as well : Ignoring accented letters in string comparison

Event RemoveDiacritics method at that thread fails

1

There are 1 best solutions below

1
On BEST ANSWER

This compares all those strings as equal:

string.Compare(s1,s2,
               CultureInfo.InvariantCulture,
               CompareOptions.IgnoreNonSpace | CompareOptions.IgnoreCase)