https://docs.microsoft.com/en-us/dotnet/csharp/programming-guide/classes-and-structs/how-to-initialize-objects-by-using-an-object-initializer
call default constructor, set parameters with values
// Make the same declaration by using an object initializer and sending // arguments for the first and last names. The default constructor is // invoked in processing this declaration, not the constructor that has // two parameters. StudentName student2 = new StudentName { FirstName = "Craig", LastName = "Playstead" };
call default constructor, set parameters with values
// Make the same declaration by using an object initializer and sending // arguments for the first and last names. The default constructor is // invoked in processing this declaration, not the constructor that has // two parameters. StudentName student2 = new StudentName { FirstName = "Craig", LastName = "Playstead" };
No comments:
Post a Comment