Evaluation of assignment in C# : <p>In C++ you can evaluate assignment as a condition, as shown here: <a href="https://stackoverflow.com/questions/2003895/in-c-what-causes-an-assignment-to-evaluate-as-true-or-false-when-used-in-a-con">In C++ what causes an assignment to evaluate as true or false when used in a control structure?</a></p>

<p>I tried the same thing in C# and it doesn't seem to work.</p>

<pre><code>public class Solution {
    static int _x = 0;
    public static bool DoStuff() {


        if (_x &gt; 10) {
            return false;
        } else {
            ++_x;
            return true;
        }
    }
    public static void Main(string[] args) {

        bool didStuff = false;
        while (didStuff = DoStuff()) {
            Console.WriteLine("You shouldn't see this more than 10 times...");
        }

        if( didStuff) {
            Console.WriteLine("Girl, you know it's true.");
        }

    }
}
</code></pre>

<p>Output:</p>

<pre><code>You shouldn't see this more than 10 times...
You shouldn't see this more than 10 times...
You shouldn't see this more than 10 times...
You shouldn't see this more than 10 times...
You shouldn't see this more than 10 times...
You shouldn't see this more than 10 times...
You shouldn't see this more than 10 times...
You shouldn't see this more than 10 times...
You shouldn't see this more than 10 times...
You shouldn't see this more than 10 times...
You shouldn't see this more than 10 times...
</code></pre>

<p>I expected to see, "Girl, you know it's true.", as the last line in the console window.</p>

<p>The while seems to evaluate to true, but something is amiss with the assignment. Can anyone explain why I did not see the final output to console?</p>
