title: Problem with debug watch in Visual Studio with yield return enumerator methods
body: <p>I have a method which returns an <code>IEnumerable&lt;&gt;</code> which it builds up using the <code>yield return</code> syntax:</p>
  
  <pre><code>namespace Validation
  {
      public class UserValidator
      {
          public IEnumerable&lt;ValidationError&gt; Validate(User user)
          {
              if (String.IsNullOrEmpty(user.Name))
              {
                  yield return new ValidationError("Name", ValidationErrorType.Required);
              }
  
              [...]
  
              yield break;
          }
      }
  }
  </code></pre>
  
  <p>If I put a breakpoint in the method, I can step over each line, but if I try to use the Watch or Immediate windows to view the value of a variable I get this error:</p>
  
  <blockquote>
    <p>Cannot access a non-static member of
    outer type 'Validation.UserValidator.Validate' via
    nested type 'Validation.UserValidator'</p>
  </blockquote>
  
  <p>Does anyone know why this is and how I can get around it?</p>