Thursday, 20 February 2014

how to create array of object in List

Create the array of object in the list at the time of initiations.
  List<Employee> players = new List<Employee>
       {
           new Employee { Name = "John", Designation= "Manager" },
           new Employee { Name = "Ross", Designation = "Worker" },
           new Employee { Name = "Eric", Designation = "leader" },
           new Employee { Name = "Josh", Designation = "Manager" },
           new Employee { Name = "Mandy", Designation = "Worker" },
           new Employee { Name = "Flora", Designation = "Manager" },
           new Employee { Name = "Garry", Designation = "Worker" },
           new Employee { Name = "Joseph", Designation = "Worker"},
           new Employee { Name = "Murray", Designation = "leader"},
           new Employee { Name = "Henry", Designation = "leader"},
           new Employee { Name = "Watson", Designation = "Worker"},
           new Employee { Name = "Linda", Designation = "Manager"}
       };
There are creating the array of the list object at the time of initiations.

No comments:

Post a Comment