So
Person p1 = new Person("Jacqualine", "Chow"); Person p2 = new Person("Andre", "Meurer"); Person p3 = new Person("Alex", "James"); List<Person> pList.Add(p1); pList.Add(p2); pList.Add(p3); |
can be written as
List<Person> |
and in combining the power of object initializer, this will become
List<Person> pList = new List<Person> { new Person { Firstname = "Jacqualine", Lastname = "Chow" }, new Person { Firstname = "Andre", Lastname = "Meurer" }, new Person { Firstname = "Alex", Lastname = "James" } }; |
No comments:
Post a Comment