Article View: borland.public.csharpbuilder.language.csharp
Article #398Re: inherited / constructors : best code ?
From: Jon Shemitz
Date: Thu, 21 Jul 2005 23:41
Date: Thu, 21 Jul 2005 23:41
23 lines
1901 bytes
1901 bytes
OD wrote:
> > "public class B() {}" is exactly
> > equivalent to "public class B(): base() {}"
> Ok, so c# will automatically and always call the first constructor in
> inheritance chain that will match the parameter list (that can be
> empty).
No, not quite. No initializer is the same as ": base()", but that's
it: C# will only call ": base(Foo)" if you explicitly code it that
way.
(The rule is that every class must ultimately call a base constructor.
If a constructor uses a ": this(/*whatever*/)" initializer, the other
constructor must call a base constructor, either directly or
indirectly. It doesn't matter if the 'main' constructor (that all the
others channel through) calls base directly (ie, ":
base(/*whatever*/)" or just by not having an ititializer.)
--
www.midnightbeach.com
Technical Details
Message-ID:
<42E03296.677A5D68@midnightbeach.com>Path:
arc1-ca.pugleaf.net!g2news1.google.com!news4.google.com!news.glorb.com!gail.ripco.com!news-out.newsfeeds.com!propagator3-LAX.newsfeeds.com!news-in.superfeed.net!caladan.landsraad.net!newsgroups.borland.com!not-for-mailReferences:
<mn.ad937d57748784b9.18651@0e-naxos.com> <42E01E73.C32A6218@midnightbeach.com> <mn.b02d7d57be39b554.18651@0e-naxos.com>Show Full Headers
Complete Article Headers
X-Google-Thread: 1efe35,40a1073c2533bd08 X-Google-Attributes: gid1efe35,public X-Google-Language: ENGLISH,ASCII-7-bit Message-ID: <42E03296.677A5D68@midnightbeach.com> Date: Thu, 21 Jul 2005 16:41:10 -0700 From: Jon Shemitz <jon@midnightbeach.com> Reply-To: jon@midnightbeach.com Organization: Midnight Beach X-Mailer: Mozilla 4.79 [en] (Windows NT 5.0; U) X-Accept-Language: en-US,en MIME-Version: 1.0 Newsgroups: borland.public.csharpbuilder.language.csharp Subject: Re: inherited / constructors : best code ? References: <mn.ad937d57748784b9.18651@0e-naxos.com> <42E01E73.C32A6218@midnightbeach.com> <mn.b02d7d57be39b554.18651@0e-naxos.com> Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit NNTP-Posting-Host: 63.249.104.197 X-Trace: newsgroups.borland.com 1121989269 63.249.104.197 (21 Jul 2005 16:41:09 -0700) Lines: 23 Path: arc1-ca.pugleaf.net!g2news1.google.com!news4.google.com!news.glorb.com!gail.ripco.com!news-out.newsfeeds.com!propagator3-LAX.newsfeeds.com!news-in.superfeed.net!caladan.landsraad.net!newsgroups.borland.com!not-for-mail