Archives

Archives / 2011 / August
  • How to make object initializers more useful

    Quite often, it's necessary to validate an object state when it's initialized. With constructor arguments, this is easy to do as it can be done at the end or beginning of the constructor code. With object initializers, it's nearly impossible, as there's no way to know programmatically when the object initialization is finished.