KnowledgeHub
Questions
Tags
Users
Search
Alex Rivera
|
Logout
Edit Question
Title
Body
Given the following example, is one objectively better/faster/safer than the other? Should object literal instantiation be a best practice where it is practical? Where is this inappropriate? class Person { public string name; public int age; } void MakePeople() { Person myPerson = new Person(); myPerson.name = "Steve"; myPerson.age = 21; Person literalPerson = new Person { name = "John", age = 22 }; }
Tags (comma-separated)
Save Edits
Cancel