Note that there are some explanatory texts on larger screens.

plurals
  1. POStringComparison vs CompareOptions in C#?
    primarykey
    data
    text
    <p><em>After reading <a href="https://stackoverflow.com/questions/10652851/difference-between-the-different-overloads-of-string-compare">this</a> I'm still confused :</em></p> <pre><code> string s1 = "hello"; string s2 = "héllo"; </code></pre> <p>The difference thing here is the accent/culture.</p> <p>The result of the following code is <code>False</code>.</p> <pre><code>Console.WriteLine(s1.Equals(s2, StringComparison.InvariantCulture)); </code></pre> <p>But Im using <em>invariant</em> culture , so it should treat é as e.( default is English ,no?)</p> <p>it seems that I have to go all the way to use </p> <pre><code>String.Compare(String, String, CultureInfo, CompareOptions) </code></pre> <p>like</p> <pre><code> string.Compare(s1, s2, CultureInfo.CurrentCulture, CompareOptions.IgnoreNonSpace) //true </code></pre> <p>But , my current culture is <code>he-IL</code> so I have no CLUE why it is working. </p> <p>so : </p> <ul> <li>I can't understand when the <code>CompareOptions</code> didn't woek although I used <code>StringComparison.InvariantCulture</code> (<sub> and please don't reference me to the msdn page , cause I've already read it and I don't fully understand their explanation </sub>)</li> <li><p>In simple words , when should I use each overload ?</p></li> <li><p>Doesn't <em><a href="http://msdn.microsoft.com/en-us/library/system.globalization.compareoptions.aspx#memberList" rel="nofollow noreferrer">nonspacing combining characters</a></em> is a culture thing ?</p></li> </ul>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload