title: Initializing lists inside properties vs. in the constructor?
body: <p>I have an object with <code>List&lt;&gt;</code>s exposed by properties. I generally initialize my lists within the property getter as follows:</p>
  
  <pre><code>public class Foo
  {
      private List&lt;bar&gt; _barList;
  
      public List&lt;bar&gt;
      {
          get
          {
              if(_barList == null)
              {
                  _barList = new List&lt;Bar&gt;()
              }
  
              return _barList;
          }
  
          set
          {
              _barList = value;
          }
      }
  
      public Foo()
      {
      }
  }
  </code></pre>
  
  <p>However, my colleagues generally prefer initializing the list in the class constructor as follows:</p>
  
  <pre><code>public class Foo
  {
      public List&lt;bar&gt; BarList { get; set; }
  
      public Foo()
      {
          BarList = new List&lt;Bar&gt;();
      }
  }
  </code></pre>
  
  <p>Both cases prevent <code>BarList</code> from being accessed before it is initialized. The second seems more neat due to the use of autoproperties. The first seems like a better option though, since the list is only initialized when it is first used.  Are there any other considerations I should take into account? Is there a best practice for this?  </p>