Ray's playground

 

Item 12: Prefer Member Initializers to Assignment Statements(Effective C#)

  Member initializers are the simplest way to ensure that the member variables in your type are initialized regardless of which constructor is called. The initializers are executed before each constructor you make for your type. Using this syntax means that you cannot forget to add the proper initialization when you add new constructors for a future release. Use initializers when all constructors create the member variable the same way;  it’s simpler to read and easier to maintain.

posted on 2011-01-21 23:37  Ray Z  阅读(191)  评论(0编辑  收藏  举报

导航