Lets assume, your constructor definition looks like this:
public Employee(string firstName, string lastName, DateTime dateOfBirth)
In that case, you have no other option in C# 3.0 other than to invoke the constructor like this:
Employee employee = new Employee ("Shweta", "Jain", new DateTime(1990, 1, 1));
So, now in this case, it is not clear about what is being assigned in the constructor (e.g., that third DateTime parameter might be date of birth, might be date hired, who knows).
In C# 4.0, you can invoke the constructor like this:
Employee employee = new Employee(firstName: "Shweta", lastName: "Jain", dateOfBirth: new DateTime(1990, 1, 1));
This expresses the intent clearly and makes the code more understandable.
Thanks on your marvelous posting! I truly enjoyed reading it, you could be a great author.I will ensure that I bookmark your blog and may come back at some point.
ReplyDeleteI want to encourage you continue your great work, have a nice
day!
Also visit my site: google plus api
Thank you for your valuable feedback
DeleteGreat Article
ReplyDeleteC# Training
Thanks John for reading
DeleteGreat Article
ReplyDeleteProject Centers in Chennai
Final Year Projects for CSE
Excellent blog and I really glad to visit your post. Keep continuing...
ReplyDeleteEmbedded System Course Chennai
Embedded Systems Course
Unix Training in Chennai
Power BI Training in Chennai
Pega Training in Chennai
Spark Training in Chennai
Linux Training in Chennai
Tableau Training in Chennai
Oracle Training in Chennai
Appium Training in Chennai