Checking if every character in a c# string is the same character
<p>Starting with any string, I need to ascertain whether that string comprises one or more instances of only a specified single character. For example "£££££" would pass my test, "wertf" would fail. The approach I have taken is as follows:</p>

<pre><code>string source = "any string";
char[] candidate = source.ToCharArray();
char validCharacter = '£';

    if (candidate.Length &gt; 0)
    {
        // (code removed) if candidate length = 1 then just test candidate[0] against validCharacter
        bool isValid = true;
        int index = 0;

        while (index &lt; candidate.Length - 1)
        {
            if (candidate [index] != validCharacter )
            {
                isValid = false;
                break;
            }

            index++;
        }

        if (isValid)
        {
            // success, do what needs doing
        }
    }
</code></pre>

<p>This works, as you would expect, but I can't help but feel that I might be missing a trick here. Is there a better, more concise, way of doing this that doesn't sacrifice the clarity of the above?</p>
