Constructor Usage - C# Coding Standard 8

Every class should have minimum one constructor. While adding class in Microsoft Visual Studio, it will not contain any constructor. Adding at least one constructor with or without parameters will prevent serialization issues in the future. Add protected constructor instead private constructor if you want to get it used in derived class. You need to declare constructor as static for static class.

  • Don't call any methods inside the constructor and don't do anything that could cause an exception because it is very difficult to catch exceptions inside the constructor.
  • Don't use this reference in any constructor unless it is invoking another constructor.
  • Use only set property values in constructor.