Entries:
Comments:
Posts:

Loading User Information from Channel 9

Something went wrong getting user information from Channel 9

Latest Achievement:

Loading User Information from MSDN

Something went wrong getting user information from MSDN

Visual Studio Achievements

Latest Achievement:

Loading Visual Studio Achievements

Something went wrong getting the Visual Studio Achievements

Mihai Morariu

Mihai Morariu MihaiMorariu

Niner since 2012

  • Working with Collections - 21

    Thank you for your help, Duncan ! It makes sense now.

     

    Regards,

    Mihai

  • Working with Collections - 21

    Hello Fred,

     

    Thank you for your reply.

    I was not referring to the curly braces, but the parantheses. What I'm saying is that in the beginning of the video the "car1" object is initialized with the following line:

    • Car car1 = new Car();

    As you said, we are using the paranthesis here since we are calling the default constructor. However, later in the video (21:00), when initializing the collection, Mr. Tabor is using the following line:

    • List<Car> myList = new List<Car> {

              new Car { Make = "Oldsmobile", Model = "Cutlas Supreme" } ...

    See the difference? There is no () here when creating the Car object. This is what I was talking about.

     

    Regards,

    Mihai

  • Working with Collections - 21

    Hello Mr. Tabor,

     

    First of all, thank you for the series. It's awesome and has helped me a lot.

    There is one thing, though, that I don't understand in this video. Why is it that when you are creating a Car object you are using the sytnax

    • Car car1 = new Car()   (with parantheses)

    but when you are initializing the collection you are using

    • new Car { Make = "Oldsmobile", Model = "Cutlas Supreme" }  (without parantheses)
     
    I hope my question does not sound stupid, but why exactly do we use parantheses in one case but do not in the other?
     
     
    Thank you,
     
    Mihai Morariu