title: C# Debugging functions that contain lambda expressions
body: <p>I have a function with a lambda expression something like:</p>
  
  <pre><code>int maxOccurrences = ( from field in data select field ).Max( f =&gt; f.Occurrences )
  </code></pre>
  
  <p>P.S. I'm sure that there's a nicer / neater / more idiomatic version of the above statement, it might be nice to know what that might be, although its not important to the question!</p>
  
  <p>If I modify anything else within the function whilst debugging say a <code>Console.Write</code> expression, the debugger states:</p>
  
  <blockquote>
    <p>Modifying a 'method' which contains a lambda expression will prevent the debug session from continuing while Edit and Continue is enabled.</p>
  </blockquote>
  
  <p>I was wondering why this might be the case?</p>
  
  <p>I would have thought that the IL generated for the lamba function and the <code>Console.Write</code> statement would be separate and that the Debugger could alter and modify when necessary. Is there some fundamental concept that I'm missing concerning the lamda functionality?</p>