I have two strings one with a double-byte value and the other is a single byte-one. The string comparison result returns false, how do I get them to compare correctly after ignoring the single-byte/double-byte difference?
string s1 = "smatsumoto11"
string s2 = "smatsumoto11"
In the same scenario, if you have a nvarchar column in SQL server which contains the value smatsumoto11, a query to fetch the data with the where condition having the string smatsumoto11 will return the same row. I need similar semantics with C# string comparison.
I have tried a few options mentioned on MSDN but they don’t seem to work.
Any ideas?
Your
s1contains so-called “fullwidth” characters, so you can usestring.Compareand tell it to ignore character width:(Of course, specify a different
CultureInfoif necessary.)