鉴于以下示例,客观上是否比另一个更好/更快/更安全?对象文字实例化是否应该是可行的最佳实践?
这哪里不合适?
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 };
}