title: Best practice for placement of local variable declaration inside method?
body: <p>Is the C# best practice to declare all local variables at the top of the method or to declare them right at their first use?</p>
  
  <p>Example 1:</p>
  
  <pre><code>void myMethod()
  {
      var example = String.Empty;
      var xmlDoc = new XmlDocument();
  
      xmlDoc.LoadXml("c:\my.xml");
      example = doc.SelectSingleNode("//TestNode").OuterXml;
  }
  </code></pre>
  
  <p>Example 2:</p>
  
  <pre><code>void myMethod()
  {
      var xmlDoc = new XmlDocument();
  
      xmlDoc.LoadXml("c:\my.xml");
      var example = doc.SelectSingleNode("//TestNode").OuterXml;
  }
  </code></pre>