What am I doing wrong with C# object initializers?
问题 When i initialize an object using the new object initializers in C# I cannot use one of the properties within the class to perform a further action and I do not know why. My example code: Person person = new Person { Name = "David", Age = "29" }; Within the Person Class, x will equal 0 (default): public Person() { int x = Age; // x remains 0 - edit age should be Age. This was a typo } However person.Age does equal 29. I am sure this is normal, but I would like to understand why. 回答1: The