Skip to main content

All Questions

2 votes
1 answer
9k views

Should I initialize a member variable in declaration when it is initialized by a constructor parameter?

Which is recommended for initialization of class fields in C#: class Foo { public X x = new X(); // or any default value... public Foo(X _x) { x = _x; } } Or class Foo { ...
Ahmad's user avatar
  • 1,866