title: Why can I create an instance of a class without storing it to a variable and still have everything work?
body: <p>I have a non-static class called <code>ImplementHeaderButtons</code> which contains a non-static public method called <code>Implement</code>. The name of the class and method are not important, what's important is that they are not static, so they need to be instantiated in order to be used, right?</p>
  
  <p>So I used to do this:</p>
  
  <pre><code>var implementHeaderButtons = new ImplementHeaderButtons();
  implementHeaderButtons.Implement(this, headerButtons);
  </code></pre>
  
  <p>But then I decided to play around a bit with it (actually I was looking for a way to make it a one-liner) and I concluded that the following code works just as well:</p>
  
  <pre><code>new ImplementHeaderButtons().Implement(this, headerButtons);
  </code></pre>
  
  <p>Now, I do not need a variable to hold the instance, but my question is: <strong>how come I can create a new instance of a class on the fly and call a method of it without having a variable to store the instance?</strong></p>
  
  <p>I wouldn't be surprised if it didn't work as intended, but it does.</p>