如果我在实例化对象时使用对象初始化程序,该对象构造函数是否可以访问已初始化的属性?
public class ExampleClass {
public string proptery1 { get; set; }
public string property2 { get; set; }
public ExampleClass() {
if(!string.IsNullOrEmpty(property1)) {
...
}
}
}
ExampleClass exampleClass = new ExampleClass() {
property1 = "hello",
property2 = "world"
};