title: Adding item to list using constructor C#
body: <p>I am learning C# and was trying different ways to add to list. I tried two different method below . First One <strong>does not work</strong>, second <strong>one does work</strong>.</p>
  
  <p>What is wrong with first method?</p>
  
  <pre><code> class Program
      {
          static void Main(string[] args)
          {
              Employee emps = new Employee();
              emps.PromoteEmp(emps.emp);
          }
      }
  
      class Employee
      {
          public int ID { get; set; }
          public string Name { get; set; }
          public int Salary { get; set; }
          public int Experience { get; set; }
          public List&lt;Employee&gt; emp;
  
          public Employee()
          {
              emp = new List&lt;Employee&gt;();
              emp.Add(new Employee() { ID = 1, Name = "A", Experience = 6, Salary = 30000 });
              emp.Add(new Employee() { ID = 2, Name = "B", Experience = 4, Salary = 10000 });
              emp.Add(new Employee() { ID = 1, Name = "C", Experience = 5, Salary = 15000 });
              emp.Add(new Employee() { ID = 1, Name = "D", Experience = 8, Salary = 60000 });
          }
  
          public void PromoteEmp(List&lt;Employee&gt; empList)
          {
              foreach (Employee item in empList)
              {
                  if (item.Experience &gt; 5)
                  {
                      Console.WriteLine(item.Name + " promoted ");
                  }
              }
          }
      }
  </code></pre>
  
  <p><strong>Second Method</strong></p>
  
  <pre><code> class Program
      {
          static void Main(string[] args)
          {
              Employee emps = new Employee();
              emps.AddToList();
              emps.PromoteEmp(emps.emp);
          }
      }
  
      class Employee
      {
          public int ID { get; set; }
          public string Name { get; set; }
          public int Salary { get; set; }
          public int Experience { get; set; }
          public List&lt;Employee&gt; emp;
  
  
          public void AddToList()
          {
            emp = new List&lt;Employee&gt;();
            emp.Add(new Employee() { ID = 1, Name = "A", Experience = 6, Salary = 30000 });
            emp.Add(new Employee() { ID = 2, Name = "B", Experience = 4, Salary = 10000 });
           emp.Add(new Employee() { ID = 1, Name = "C", Experience = 5, Salary = 15000 });
           emp.Add(new Employee() { ID = 1, Name = "D", Experience = 8, Salary = 60000 });
          }
  
          public void PromoteEmp(List&lt;Employee&gt; empList)
          {
              foreach (Employee item in empList)
              {
                  if (item.Experience &gt; 5)
                  {
                      Console.WriteLine(item.Name + " promoted ");
                  }
              }
          }
      }
  </code></pre>
  
  <p>Thank You :)</p>