proper constructor chaining direction<p>I was looking at some code at my work and with several overloaded constructors having the same code in each one, I thought, beautiful, perfect place to use constructor chaining.  Except I'm not sure which direction is the proper way to go?</p> <p>What I mean is, in the constructor, do you go from the general to the specific, using nulls for the missing parameters, or do you go from specific to general and then in the body of the constructor set the missing properties?</p> <p>Where things get interesting is when you want to call the base constructor, should it go in one place?  If you're using constructor chaining, then you can do this, but where does it go, at the top or the bottom of the chain?</p> <p>Here is a sample class that illustrates what I mean.</p> <p><font color="#0000ff" size=2>namespace</font><font size=2> ConstructorChaining</p> <p>{</p> <p></font><font color="#0000ff" size=2>class</font><font size=2> </font><font color="#2b91af" size=2>Base</p></font><font size=2> <p>{</p> <p></font><font color="#0000ff" size=2>public</font><font size=2> </font><font color="#2b91af" size=2>StringBuilder</font><font size=2> orderOfExecution = </font><font color="#0000ff" size=2>new</font><font size=2> </font><font color="#2b91af" size=2>StringBuilder</font><font size=2>();</p> <p></font><font color="#0000ff" size=2>public</font><font size=2> Base()</p> <p>{</p> <p>orderOfExecution.Append(</font><font color="#a31515" size=2>&quot;Base()\n&quot;</font><font size=2>);</p> <p>}</p> <p></font><font color="#0000ff" size=2>public</font><font size=2> Base(</font><font color="#2b91af" size=2>String</font><font size=2> OrderOfExecution)</p> <p>{</p> <p>orderOfExecution.Append(</font><font color="#a31515" size=2>&quot;Base(String &quot;</font><font size=2> + OrderOfExecution + </font><font color="#a31515" size=2>&quot;)\n&quot;</font><font size=2>);</p> <p>}</p> <p>}</p> <p></font><font color="#0000ff" size=2>class</font><font size=2> </font><font color="#2b91af" size=2>ConstructorChaining</font><font size=2> : </font><font color="#2b91af" size=2>Base</p></font><font size=2> <p>{</p> <p></font><font color="#0000ff" size=2>public</font><font size=2> ConstructorChaining()</p> <p>: </font><font color="#0000ff" size=2>this</font><font size=2>(</font><font color="#0000ff" size=2>null</font><font size=2>) </font><font color="#008000" size=2>//calling the more specialized constructor passing null to the more specific constructor</p></font><font size=2> <p>{</p> <p>orderOfExecution.Append(</font><font color="#a31515" size=2>&quot;GeneralToSpecific()\n&quot;</font><font size=2>);</p> <p>}</p> <p></font><font color="#0000ff" size=2>public</font><font size=2> ConstructorChaining(</font><font color="#2b91af" size=2>String</font><font size=2> NewOrderOfConstruction)</p> <p>{</p> <p>orderOfExecution.Append(</font><font color="#a31515" size=2>&quot;GeneralToSpecific(String &quot;</font><font size=2> + (NewOrderOfConstruction == </font><font color="#0000ff" size=2>null</font><font size=2> ? </font><font color="#a31515" size=2>&quot;NULL&quot;</font><font size=2> : NewOrderOfConstruction) + </font><font color="#a31515" size=2>&quot;)\n&quot;</font><font size=2>);</p> <p>}</p> <p>}</p> <p></font><font color="#0000ff" size=2>class</font><font size=2> </font><font color="#2b91af" size=2>SpecificToGeneral</font><font size=2> : </font><font color="#2b91af" size=2>Base</p></font><font size=2> <p>{</p> <p></font><font color="#0000ff" size=2>public</font><font size=2> SpecificToGeneral()</p> <p>{</p> <p>orderOfExecution.Append(</font><font color="#a31515" size=2>&quot;SpecificToGeneral()\n&quot;</font><font size=2>);</p> <p>}</p> <p></font><font color="#0000ff" size=2>public</font><font size=2> SpecificToGeneral(</font><font color="#2b91af" size=2>String</font><font size=2> NewOrderOfConstruction)</p> <p>: </font><font color="#0000ff" size=2>this</font><font size=2>() </font><font color="#008000" size=2>//call the general case of the constructor</p></font><font size=2> <p>{</p> <p>orderOfExecution.Append(</font><font color="#a31515" size=2>&quot;SpecificToGeneral(String &quot;</font><font size=2> + (NewOrderOfConstruction == </font><font color="#0000ff" size=2>null</font><font size=2> ? </font><font color="#a31515" size=2>&quot;NULL&quot;</font><font size=2> : NewOrderOfConstruction) + </font><font color="#a31515" size=2>&quot;)\n&quot;</font><font size=2>);</p> <p>}</p> <p>}</p> <p>}</p></font><font color="#0000ff" size=2> <p></font><font size=2></font> </p> <p><font size=2>Code to run it is here</font></p> <p><font size=2></font> </p><font size=2><font color="#0000ff" size=2> <p>namespace</font><font size=2> ConstructorChaining</p> <p>{</p> <p></font><font color="#0000ff" size=2>public</font><font size=2> </font><font color="#0000ff" size=2>partial</font><font size=2> </font><font color="#0000ff" size=2>class</font><font size=2> </font><font color="#2b91af" size=2>Form1</font><font size=2> : </font><font color="#2b91af" size=2>Form</p></font><font size=2> <p>{</p> <p></font><font color="#0000ff" size=2>public</font><font size=2> Form1()</p> <p>{</p> <p>InitializeComponent();</p> <p></font><font color="#2b91af" size=2>Console</font><font size=2>.WriteLine(</font><font color="#a31515" size=2>&quot;General To Specific&quot;</font><font size=2>);</p> <p></font><font color="#2b91af" size=2>ConstructorChaining</font><font size=2> generalToSpecific1 = </font><font color="#0000ff" size=2>new</font><font size=2> </font><font color="#2b91af" size=2>ConstructorChaining</font><font size=2>();</p> <p></font><font color="#2b91af" size=2>Console</font><font size=2>.WriteLine(generalToSpecific1.orderOfExecution.ToString());</p> <p></font><font color="#2b91af" size=2>ConstructorChaining</font><font size=2> generalToSpecific2 = </font><font color="#0000ff" size=2>new</font><font size=2> </font><font color="#2b91af" size=2>ConstructorChaining</font><font size=2>(</font><font color="#a31515" size=2>&quot;InstantiatingVariable&quot;</font><font size=2>);</p> <p></font><font color="#2b91af" size=2>Console</font><font size=2>.WriteLine(generalToSpecific2.orderOfExecution.ToString());</p> <p></font><font color="#2b91af" size=2>Console</font><font size=2>.WriteLine(</font><font color="#a31515" size=2>&quot;Specific To General&quot;</font><font size=2>);</p> <p></font><font color="#2b91af" size=2>SpecificToGeneral</font><font size=2> specificToGeneral1 = </font><font color="#0000ff" size=2>new</font><font size=2> </font><font color="#2b91af" size=2>SpecificToGeneral</font><font size=2>();</p> <p></font><font color="#2b91af" size=2>Console</font><font size=2>.WriteLine(specificToGeneral1.orderOfExecution);</p> <p></font><font color="#2b91af" size=2>SpecificToGeneral</font><font size=2> specificToGeneral2 = </font><font color="#0000ff" size=2>new</font><font size=2> </font><font color="#2b91af" size=2>SpecificToGeneral</font><font size=2>(</font><font color="#a31515" size=2>&quot;InstantiatingVariable&quot;</font><font size=2>);</p> <p></font><font color="#2b91af" size=2>Console</font><font size=2>.WriteLine(specificToGeneral2.orderOfExecution);</p> <p>}</p> <p>}</p> <p>}</p> <p> </p> <p> </p> <p>And the sample output is</p> <p> </p><font size=1> <p>General To Specific</p> <p>Base()</p> <p>GeneralToSpecific(String NULL)</p> <p>GeneralToSpecific()</p> <p>Base()</p> <p>GeneralToSpecific(String InstantiatingVariable)</p> <p>Specific To General</p> <p>Base()</p> <p>SpecificToGeneral()</p> <p>Base()</p> <p>SpecificToGeneral()</p> <p>SpecificToGeneral(String InstantiatingVariable)</p></font> <p> </p></font></font>© 2009 Microsoft Corporation. All rights reserved.Thu, 23 Jul 2009 08:56:27 Zad106863-e89f-4c5b-a65a-eec1369af06chttp://social.msdn.microsoft.com/Forums/en-US/csharplanguage/thread/ad106863-e89f-4c5b-a65a-eec1369af06c#ad106863-e89f-4c5b-a65a-eec1369af06chttp://social.msdn.microsoft.com/Forums/en-US/csharplanguage/thread/ad106863-e89f-4c5b-a65a-eec1369af06c#ad106863-e89f-4c5b-a65a-eec1369af06cFlip3http://social.msdn.microsoft.com/Profile/en-US/?user=Flip3proper constructor chaining direction<p>I was looking at some code at my work and with several overloaded constructors having the same code in each one, I thought, beautiful, perfect place to use constructor chaining.  Except I'm not sure which direction is the proper way to go?</p> <p>What I mean is, in the constructor, do you go from the general to the specific, using nulls for the missing parameters, or do you go from specific to general and then in the body of the constructor set the missing properties?</p> <p>Where things get interesting is when you want to call the base constructor, should it go in one place?  If you're using constructor chaining, then you can do this, but where does it go, at the top or the bottom of the chain?</p> <p>Here is a sample class that illustrates what I mean.</p> <p><font color="#0000ff" size=2>namespace</font><font size=2> ConstructorChaining</p> <p>{</p> <p></font><font color="#0000ff" size=2>class</font><font size=2> </font><font color="#2b91af" size=2>Base</p></font><font size=2> <p>{</p> <p></font><font color="#0000ff" size=2>public</font><font size=2> </font><font color="#2b91af" size=2>StringBuilder</font><font size=2> orderOfExecution = </font><font color="#0000ff" size=2>new</font><font size=2> </font><font color="#2b91af" size=2>StringBuilder</font><font size=2>();</p> <p></font><font color="#0000ff" size=2>public</font><font size=2> Base()</p> <p>{</p> <p>orderOfExecution.Append(</font><font color="#a31515" size=2>&quot;Base()\n&quot;</font><font size=2>);</p> <p>}</p> <p></font><font color="#0000ff" size=2>public</font><font size=2> Base(</font><font color="#2b91af" size=2>String</font><font size=2> OrderOfExecution)</p> <p>{</p> <p>orderOfExecution.Append(</font><font color="#a31515" size=2>&quot;Base(String &quot;</font><font size=2> + OrderOfExecution + </font><font color="#a31515" size=2>&quot;)\n&quot;</font><font size=2>);</p> <p>}</p> <p>}</p> <p></font><font color="#0000ff" size=2>class</font><font size=2> </font><font color="#2b91af" size=2>ConstructorChaining</font><font size=2> : </font><font color="#2b91af" size=2>Base</p></font><font size=2> <p>{</p> <p></font><font color="#0000ff" size=2>public</font><font size=2> ConstructorChaining()</p> <p>: </font><font color="#0000ff" size=2>this</font><font size=2>(</font><font color="#0000ff" size=2>null</font><font size=2>) </font><font color="#008000" size=2>//calling the more specialized constructor passing null to the more specific constructor</p></font><font size=2> <p>{</p> <p>orderOfExecution.Append(</font><font color="#a31515" size=2>&quot;GeneralToSpecific()\n&quot;</font><font size=2>);</p> <p>}</p> <p></font><font color="#0000ff" size=2>public</font><font size=2> ConstructorChaining(</font><font color="#2b91af" size=2>String</font><font size=2> NewOrderOfConstruction)</p> <p>{</p> <p>orderOfExecution.Append(</font><font color="#a31515" size=2>&quot;GeneralToSpecific(String &quot;</font><font size=2> + (NewOrderOfConstruction == </font><font color="#0000ff" size=2>null</font><font size=2> ? </font><font color="#a31515" size=2>&quot;NULL&quot;</font><font size=2> : NewOrderOfConstruction) + </font><font color="#a31515" size=2>&quot;)\n&quot;</font><font size=2>);</p> <p>}</p> <p>}</p> <p></font><font color="#0000ff" size=2>class</font><font size=2> </font><font color="#2b91af" size=2>SpecificToGeneral</font><font size=2> : </font><font color="#2b91af" size=2>Base</p></font><font size=2> <p>{</p> <p></font><font color="#0000ff" size=2>public</font><font size=2> SpecificToGeneral()</p> <p>{</p> <p>orderOfExecution.Append(</font><font color="#a31515" size=2>&quot;SpecificToGeneral()\n&quot;</font><font size=2>);</p> <p>}</p> <p></font><font color="#0000ff" size=2>public</font><font size=2> SpecificToGeneral(</font><font color="#2b91af" size=2>String</font><font size=2> NewOrderOfConstruction)</p> <p>: </font><font color="#0000ff" size=2>this</font><font size=2>() </font><font color="#008000" size=2>//call the general case of the constructor</p></font><font size=2> <p>{</p> <p>orderOfExecution.Append(</font><font color="#a31515" size=2>&quot;SpecificToGeneral(String &quot;</font><font size=2> + (NewOrderOfConstruction == </font><font color="#0000ff" size=2>null</font><font size=2> ? </font><font color="#a31515" size=2>&quot;NULL&quot;</font><font size=2> : NewOrderOfConstruction) + </font><font color="#a31515" size=2>&quot;)\n&quot;</font><font size=2>);</p> <p>}</p> <p>}</p> <p>}</p></font><font color="#0000ff" size=2> <p></font><font size=2></font> </p> <p><font size=2>Code to run it is here</font></p> <p><font size=2></font> </p><font size=2><font color="#0000ff" size=2> <p>namespace</font><font size=2> ConstructorChaining</p> <p>{</p> <p></font><font color="#0000ff" size=2>public</font><font size=2> </font><font color="#0000ff" size=2>partial</font><font size=2> </font><font color="#0000ff" size=2>class</font><font size=2> </font><font color="#2b91af" size=2>Form1</font><font size=2> : </font><font color="#2b91af" size=2>Form</p></font><font size=2> <p>{</p> <p></font><font color="#0000ff" size=2>public</font><font size=2> Form1()</p> <p>{</p> <p>InitializeComponent();</p> <p></font><font color="#2b91af" size=2>Console</font><font size=2>.WriteLine(</font><font color="#a31515" size=2>&quot;General To Specific&quot;</font><font size=2>);</p> <p></font><font color="#2b91af" size=2>ConstructorChaining</font><font size=2> generalToSpecific1 = </font><font color="#0000ff" size=2>new</font><font size=2> </font><font color="#2b91af" size=2>ConstructorChaining</font><font size=2>();</p> <p></font><font color="#2b91af" size=2>Console</font><font size=2>.WriteLine(generalToSpecific1.orderOfExecution.ToString());</p> <p></font><font color="#2b91af" size=2>ConstructorChaining</font><font size=2> generalToSpecific2 = </font><font color="#0000ff" size=2>new</font><font size=2> </font><font color="#2b91af" size=2>ConstructorChaining</font><font size=2>(</font><font color="#a31515" size=2>&quot;InstantiatingVariable&quot;</font><font size=2>);</p> <p></font><font color="#2b91af" size=2>Console</font><font size=2>.WriteLine(generalToSpecific2.orderOfExecution.ToString());</p> <p></font><font color="#2b91af" size=2>Console</font><font size=2>.WriteLine(</font><font color="#a31515" size=2>&quot;Specific To General&quot;</font><font size=2>);</p> <p></font><font color="#2b91af" size=2>SpecificToGeneral</font><font size=2> specificToGeneral1 = </font><font color="#0000ff" size=2>new</font><font size=2> </font><font color="#2b91af" size=2>SpecificToGeneral</font><font size=2>();</p> <p></font><font color="#2b91af" size=2>Console</font><font size=2>.WriteLine(specificToGeneral1.orderOfExecution);</p> <p></font><font color="#2b91af" size=2>SpecificToGeneral</font><font size=2> specificToGeneral2 = </font><font color="#0000ff" size=2>new</font><font size=2> </font><font color="#2b91af" size=2>SpecificToGeneral</font><font size=2>(</font><font color="#a31515" size=2>&quot;InstantiatingVariable&quot;</font><font size=2>);</p> <p></font><font color="#2b91af" size=2>Console</font><font size=2>.WriteLine(specificToGeneral2.orderOfExecution);</p> <p>}</p> <p>}</p> <p>}</p> <p> </p> <p> </p> <p>And the sample output is</p> <p> </p><font size=1> <p>General To Specific</p> <p>Base()</p> <p>GeneralToSpecific(String NULL)</p> <p>GeneralToSpecific()</p> <p>Base()</p> <p>GeneralToSpecific(String InstantiatingVariable)</p> <p>Specific To General</p> <p>Base()</p> <p>SpecificToGeneral()</p> <p>Base()</p> <p>SpecificToGeneral()</p> <p>SpecificToGeneral(String InstantiatingVariable)</p></font> <p> </p></font></font>Thu, 01 Mar 2007 16:01:58 Z2007-03-01T19:35:51Zhttp://social.msdn.microsoft.com/Forums/en-US/csharplanguage/thread/ad106863-e89f-4c5b-a65a-eec1369af06c#c1d56b71-afc4-48f5-b6ff-1b1d3ae193dchttp://social.msdn.microsoft.com/Forums/en-US/csharplanguage/thread/ad106863-e89f-4c5b-a65a-eec1369af06c#c1d56b71-afc4-48f5-b6ff-1b1d3ae193dcPeter Ritchiehttp://social.msdn.microsoft.com/Profile/en-US/?user=Peter%20Ritchieproper constructor chaining directionI'm not sure I follow your question.  There's only one base so there really isn't a &quot;chain&quot;; and you don't overload a constructor.<br><br>If the base's default constructor (parameter-less, if it exists) isn't applicable for the constructor of a derived class you should use whatever constructor applies in those circumstances.  If a derived constructor provides no details that could apply, I would just use the default constructor.  In your example using base(null), you're basically wasting cycles...Thu, 01 Mar 2007 17:09:54 Z2007-03-01T17:09:54Zhttp://social.msdn.microsoft.com/Forums/en-US/csharplanguage/thread/ad106863-e89f-4c5b-a65a-eec1369af06c#cb48a4d6-3a53-4afd-9e73-38cefaa7c9f1http://social.msdn.microsoft.com/Forums/en-US/csharplanguage/thread/ad106863-e89f-4c5b-a65a-eec1369af06c#cb48a4d6-3a53-4afd-9e73-38cefaa7c9f1Flip3http://social.msdn.microsoft.com/Profile/en-US/?user=Flip3proper constructor chaining direction<p>re not sure you follow</p> <p>I'm trying to figure out which way do people use the constructor chaining.</p> <p>re don't overload constructor</p> <p>hhhmmmm I don't quite agree with that.  The constructor is overloaded with two signatures in my example, one for empty parameters and one for a String parameter.  Did you mean overriding?  The constructor of the derived class does not override the base class' constructor, they are still called when/if appropriate.</p> <p>re use whatever constructor applies</p> <p>I guess I'm asking, when you want to have one constructor call another (code reuse, maintenance, etc), which direction do you go, towards the more specific (applying nulls for the missing parameters) or to the more general (with specific lines of code in the constructor setting the properties, variables not set in the more general cases).</p> <p>As an example, in the code I have here at work, the empty constructor initializes a db proxy object.  In all the other eight constructors, they each make that exact same call, so the same code is duplicated unnecessarily IMHO.  What I think should be done, is have that db proxy object initialized in one of the constructor overloaded methods (either the empty one, or the most specific constructor, the one taking the most parameters).  I hope that helps to clear things up a bit?</p> <p>Thanks.</p>Thu, 01 Mar 2007 17:51:20 Z2007-03-01T17:51:20Zhttp://social.msdn.microsoft.com/Forums/en-US/csharplanguage/thread/ad106863-e89f-4c5b-a65a-eec1369af06c#3e113863-d53b-4296-a5d5-53f1e9bb3c66http://social.msdn.microsoft.com/Forums/en-US/csharplanguage/thread/ad106863-e89f-4c5b-a65a-eec1369af06c#3e113863-d53b-4296-a5d5-53f1e9bb3c66Peter Ritchiehttp://social.msdn.microsoft.com/Profile/en-US/?user=Peter%20Ritchieproper constructor chaining directionBy not overloading, I meant you don't overload a base class's constructor.<br><br>For me, I go in the most specific direction.<br><br>I generally have a set of cumulative constructors, I then chain to the most specific constructor &quot;below&quot; the current one.<br><br>For example:<br><br>class Person<br>{<br>  int age;<br>  String name:<br>  public Person(String name)<br>  {<br>    this.name = name;<br>  }<br>  public Person(String name, int age)<br>    : this(name)<br>  {<br>    this.age = age;<br>  }<br>}Thu, 01 Mar 2007 18:12:57 Z2007-03-01T19:35:51Zhttp://social.msdn.microsoft.com/Forums/en-US/csharplanguage/thread/ad106863-e89f-4c5b-a65a-eec1369af06c#9f81682a-d471-4fa5-a1ff-1d0f022d3be6http://social.msdn.microsoft.com/Forums/en-US/csharplanguage/thread/ad106863-e89f-4c5b-a65a-eec1369af06c#9f81682a-d471-4fa5-a1ff-1d0f022d3be6Flip3http://social.msdn.microsoft.com/Profile/en-US/?user=Flip3proper constructor chaining direction<p>re don't overload base constructor</p> <p>Ah, ok, I see what you mean now.</p> <p>re cumulative constructors</p> <p>That's a good way to put it, is that indeed the technical term?</p> <p>re your Person example</p> <p>That's a good one, I can see now what you mean, so then you are not pushing a null parameter forward then.  Instead you're going backwards to the more specific constructor/method call and then inside that constructor setting the properties that are specialized to that constructor's parameter list.  Ok, I can see that logic and it makes sense.</p> <p>Thank you very much for your time and explanation.</p> <p> </p> <p> </p>Thu, 01 Mar 2007 19:40:46 Z2007-03-01T19:40:46Zhttp://social.msdn.microsoft.com/Forums/en-US/csharplanguage/thread/ad106863-e89f-4c5b-a65a-eec1369af06c#88f79ce3-cf36-4825-9628-18fabfaba9a4http://social.msdn.microsoft.com/Forums/en-US/csharplanguage/thread/ad106863-e89f-4c5b-a65a-eec1369af06c#88f79ce3-cf36-4825-9628-18fabfaba9a4Peter Ritchiehttp://social.msdn.microsoft.com/Profile/en-US/?user=Peter%20Ritchieproper constructor chaining direction<div class=quote><table width="85%"><tr><td class=txt4> <strong>Flip wrote:</strong></td></tr><tr><td class=quoteTable><table width="100%"><tr><td width="100%" valign=top class=txt4> <p>re cumulative constructors</p> <p>That's a good way to put it, is that indeed the technical term?</p> <p></td></tr></table></td></tr></table></div>I've never heard the term &quot;cumulative constructors&quot; anywhere; I just used that to describe the multiple constructor case and how I implement it.  Feel free to use the term :-).<div class=quote><table width="85%"><tr><td class=txt4> <strong>Flip wrote:</strong></td></tr><tr><td class=quoteTable><table width="100%"><tr><td width="100%" valign=top class=txt4></p> <p>re your Person example</p> <p>That's a good one, I can see now what you mean, so then you are not pushing a null parameter forward then.  Instead you're going backwards to the more specific constructor/method call and then inside that constructor setting the properties that are specialized to that constructor's parameter list.  Ok, I can see that logic and it makes sense.</p> <p></td></tr></table></td></tr></table></div>It follows the same logic as not assigning default values to instance members (the <a title="http://www.gotdotnet.com/team/fxcop/docs/rules/Performance/DoNotInitializeUnnecessarily.html" href="http://www.gotdotnet.com/team/fxcop/docs/rules/Performance/DoNotInitializeUnnecessarily.html">DoNotInitializeUnnecessarily</a> rule).  No logic errors will come from using &quot;this(null)&quot;; it's just redundant. </p>Thu, 01 Mar 2007 20:06:20 Z2007-03-01T20:06:20Zhttp://social.msdn.microsoft.com/Forums/en-US/csharplanguage/thread/ad106863-e89f-4c5b-a65a-eec1369af06c#de6d8ee9-fffc-4e21-9d7b-527c6f4c90eehttp://social.msdn.microsoft.com/Forums/en-US/csharplanguage/thread/ad106863-e89f-4c5b-a65a-eec1369af06c#de6d8ee9-fffc-4e21-9d7b-527c6f4c90eequidProMShttp://social.msdn.microsoft.com/Profile/en-US/?user=quidProMSproper constructor chaining directioni disagree with the peter ritchie way.   it leads to side effects. it does not localize changes. it does not extend to initializing with other than default.  In this example, the default constructor initializes id to a poison pill value that is helpful during development to spot unitialized objects.  All the work is always done in the most specialized (most passed parameters) version; instead of being scattered. Also my understanding is this way is very efficient.<br/><br/><span class=Apple-style-span style="text-transform:none;text-indent:0px;border-collapse:separate;font:16px 'Times New Roman';white-space:normal;letter-spacing:normal;color:#000000;word-spacing:0px"><span class=Apple-style-span style="font-family:verdana;font-size:12px"> <pre class=preVariableHeight style="font-family:'Courier New', Courier, monospace;color:#000066;font-size:12px">public class MyClass { int id;<br/> string name;<br/><br/><br/> <br/> public MyClass() : this( int.MinValue, string.empty ) { } public MyClass( int Id) : this( Id, string.empty) { } public MyClass( int Id, string Name) {<br/> id = Id;<br/> name = Name; } }</pre> </span></span>Thu, 23 Jul 2009 04:59:56 Z2009-07-23T04:59:56Zhttp://social.msdn.microsoft.com/Forums/en-US/csharplanguage/thread/ad106863-e89f-4c5b-a65a-eec1369af06c#9f6f8b66-97f7-4b2b-8299-b447b242099chttp://social.msdn.microsoft.com/Forums/en-US/csharplanguage/thread/ad106863-e89f-4c5b-a65a-eec1369af06c#9f6f8b66-97f7-4b2b-8299-b447b242099cMatthew Watsonhttp://social.msdn.microsoft.com/Profile/en-US/?user=Matthew%20Watsonproper constructor chaining directionI'm not sure why you'd need a &quot;poison pill&quot; default constructor - if you omit the default constructor altogether then no user code can create an object that way, so you'd never need to check that situation.Thu, 23 Jul 2009 08:56:27 Z2009-07-23T08:56:27Z