Object and Collection Initializers - Day 2 - Part 7

Play Object and Collection Initializers - Day 2 - Part 7
Sign in to queue

The Discussion

  • User profile image

    Great video, always good to use less lines of code. Less is more, as they say

  • User profile image

    The second shortened code example only does not show anything in the textblock when the button is clicked... the last code example works perfectly...

    I tried to see what the error is but I didn't see anything wrong and this was no bugs so...

    List<Car> myList = new List<Car>();
                    Car car1 = new Car() { Make = "Oldsmobile", Model = "Cutlas Supreme" };
                   Car car2 = new Car() { Make = "Geo", Model = "Prism" };
                   Car car3 = new Car() { Make = "Nissan", Model = "Altima" };

  • User profile image

    this is because you still need to add the cars to the list:




Add Your 2 Cents