Nested Methods? Why are they useful?
<p>So I'm just learning some new stuff in C# &amp; Python. Turns out both lanuages support nested methods (C# sort of does). </p>

<p>Python:</p>

<pre><code>def MyMethod():

    print 'Hello from a method.'

    def MyInnerMethod():
        print 'Hello from a nested method.'

    MyInnerMethod()
</code></pre>

<p>C# (using new features in .NET 3.5):*</p>

<pre><code>static void Main()
{
    Console.WriteLine("Hello from main.");

    Func&lt;int, int&gt; NestedMethod =
        (x) =&gt;
        {
            Console.WriteLine("In nested method. Value of x is {0}.", x);
            return x;
        };

    int result = NestedMethod(3);
}
</code></pre>

<p>So why are nested methods so important? What makes them useful?</p>

<p><hr></p>

<p>*<em>The C# code has not been tested. Feel free to edit if it doesn't compile.</em></p>
