title: Get object initialization syntax from C# list
body: <p>I have a List of type employee.  </p>
  
  <pre><code>public class Employee
      {
          public string Name { get; set; }
          public int Id { get; set; }
          public string Level { get; set; }
      }
  
  List&lt;Employee&gt; empList = new List&lt;Employee&gt;();
  </code></pre>
  
  <p>Assume if this list has 10 items, from this list, I want to generate object initialization code. So basically I should get a string like this:</p>
  
  <pre><code>    "Employee e = new Employee{Name: "A", Id:1, Level:1};
      Employee e = new Employee{Name: "B", Id:2, Level:2};
      Employee e = new Employee{Name: "C", Id:3, Level:1};
  Employee e = new Employee{Name: "D", Id:4, Level:6};
      Employee e = new Employee{Name: "E", Id:5, Level:2};
      Employee e = new Employee{Name: "F", Id:6, Level:5}
  Employee e = new Employee{Name: "G", Id:7, Level:4};
      Employee e = new Employee{Name: "H", Id:8, Level:3};
      Employee e = new Employee{Name: "I", Id:9, Level:1};
  Employee e = new Employee{Name: "J", Id:10, Level:1}";
  </code></pre>
  
  <p>The reason I am doing this is, I am getting list of records from database but it does not have a sort order (another property). I need to manually add the sort order to each item (hard code). 
  So if I don't automate this, the only other option I will have would require me to create the object manually(instead of getting the values from database) and add SortOrder property to each object. </p>