Consider I have
public class ClassA { public string PropertyB { get; set; } } And then I use it like this
public class ClassD { static readonly ClassA PropertyE = new ClassA(); static ClassD() { PropertyE.PropertyB = "valueF"; } } but the rest of the code didn't work as I expected. Then I rewrote ClassD, and it worked
public class ClassD { static readonly ClassA PropertyE = new ClassA { PropertyB = "valueF" }; } In which way are these two code samples different? I expected that they had the same behavior, but they don't.