Object Initializers
/*
A superior, best practice, efficient, evolving way to passing parameters into a method,
based on the scenario the parameters for a method could one day change.
Book Example :
○ There exists a class name book, with getters setters for project
○ In the main, a new instance of book is created and parameters pass
via a Object Initializer method.
Though not displayed here, in the class 'Book' we might have a method called
'getBookID'. This method would work on the
values of the parameters passed in via the Object initializer technique.
*/
public class Book
{
public int BookID { get; set; }
public string BookName { get; set; }
public string AuthorName { get; set; }
public string ISBN { get; set; }
}
//main area, responsible for passing the params in.
class BookApp
{
static void Main(string[] args)
{
Book book = new Book
{
BookID = 1,
BookName = "MVC Music Store Tutorial",
AuthorName = "Jon Galloway",
ISBN = "NA"
};
Console.WriteLine(book.BookName);
}
}