title: C#- using a variable in an 'enclosing' local scope?
body: <p>I am trying to add some new features to a C# application- in particular, trying to replicate some of its behavior, but inside a web browser, rather than in the application, as it currently is.</p>
  
  <p>I am trying to call a method that has been defined in the <code>Browser.cs</code> class from inside a method in the <code>MainWindow.cs</code> class.</p>
  
  <p>The method is defined in <code>Browser.cs</code> with:</p>
  
  <pre><code>public partial class Browser : Form{
      public Browser(){
          ...
      }
      public void Browser_Load(object sender, EventArgs e){
          webKitBrowser1.Navigate("https://google.com");
      }
      ...
  }
  </code></pre>
  
  <p>I am then trying to call it from <code>MainWindow.cs</code> as follows:</p>
  
  <pre><code>public partial class MainWindow : Window{
      ...
      public MainWindow(){
          ...
          Browser mBrowser = new Browser();
          Object sender = new Object();
          EventArgs e = new EventArgs();
          mBrowser.Browser_Load(sender, e);
          ...
      }
      ...
  }
  </code></pre>
  
  <p>But, I'm getting a compile error that says:</p>
  
  <blockquote>
    <p>A local or parameter named 'e' cannot be declared in this scope because that name is used in an enclosing local scope to define a local or parameter</p>
  </blockquote>
  
  <p>What does this mean? I've never come across this error before- I am using the variable inside the same scope as where it has been declared- what does it mean by 'enclosing local scope'? Is that because I'm using <code>e</code> inside the parenthesis for the method call to <code>mBrowser.Browser_Load(sender, e)</code>?</p>
  
  <p>Surely, since the call to this method is inside the same scope as where I've defined <code>e</code>, it shouldn't be an issue of scope?</p>
  
  <p>I did try performing the call with:</p>
  
  <pre><code>mBrowser.Browser_Load(sender, EventArgs e);
  </code></pre>
  
  <p>but this gave me a compile error saying:</p>
  
  <blockquote>
    <p>'EventArgs' is a type, which is not valid in the given context.</p>
  </blockquote>
  
  <p>Can anyone point out what I'm doing wrong here, and what I should be doing to be able to call this method correctly?</p>