title: Explanation of left and right side of statement when creating new class instance
body: <p>I have a class</p>
  
  <pre><code>public class Table
  {
      public string color {get; set;}
      public string height {get; set;}
  }
  </code></pre>
  
  <p>When I want to create a new instance of this class I use:</p>
  
  <pre><code>//1.
  var myTable = new Table();
  </code></pre>
  
  <p>or</p>
  
  <pre><code>//2.
  Table myTable = new Table();
  </code></pre>
  
  <p>or</p>
  
  <pre><code>//3.
  IEnumerable&lt;Table&gt; Tables = new List&lt;Table&gt;();
  </code></pre>
  
  <p>but not</p>
  
  <pre><code>//4.
  List&lt;Table&gt; y = new IEnumerable&lt;Table&gt;();
  </code></pre>
  
  <p>Can somebody explain what the left side (var / Table / IEnumerable) is doing and what the right side (new Table / new List() etc) in contrast is doing.</p>
  
  <p>Why are they the same sometimes (eg 2) and different at other times (eg 3).</p>
  
  <p>What's the difference between these three:</p>
  
  <pre><code>var Tables = new List&lt;Table&gt;();
  List&lt;Table&gt; Tables = new List&lt;Table&gt;();
  IEnumerable&lt;Table&gt; Tables = new List&lt;Table&gt;();
  </code></pre>
  
  <p>I know this is basic stuff, but I have not found a clear explanation of what the left and right-hand side of the statement means when creating an instance of a class in C# - online.</p>
  
  <p>thx.</p>