Issue comparing Registry Key Value Names using string methods
<p>Ok guys, I'm having a really strange issue where I'm looking at Regedit right now and I can see the reg key that I'm looking for exists.</p>

<p>This is the code I'm using to detect it</p>

<pre><code>public static void GetSoeRegKey()
{
    RegistryKey soeKey = Registry.CurentUser.OpenSubKey("TechTools", true);

    if (soeKey != null)
    {
        foreach (string value in soeKey.GetValueNames())
        {
            //Here's where the problem lies
            if (value.Equals("SOEEncPass"))
                System.Diagnostics.Debug.WriteLine(value);
        }
    }
}
</code></pre>

<p>So, I've stepped through the code, and every time it is finding the reg key and the <code>soeKey.GetValueNames()</code> method is returning the values correctly.</p>

<p>However, even though I can clearly see that the value that I'm searching for is being returned the <code>if (value.Equals("SOEEncPass"))</code> never evaluates to true.</p>

<p>I've tried it as <code>value == "SOEEncPass"</code> and <code>string.Compare(value, "SOEEncPass")</code> with all of the <code>StringComparision</code> options but no matter what I do the line <code>System.Diagnostics.Debug.WriteLine(value);</code> is never executed.</p>

<p>Am I missing something with the string comparison, or is there a quirk to reg keys that I'm not aware of?</p>