Re: Overriding constructors

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance

From: Cowboy (NoSpamMgbworld_at_comcast.netNoSpamM)
Date: 05/18/04


Date: Tue, 18 May 2004 13:29:30 -0500

You should be able to write a constructor for your class and explicitly call
the base implementation, effectively overriding it. You can also overload
the constructor, if you need params passed in when you create the object. I
have not tried with ServiceBase, in particular, but your new derived class
can have a default constructor as well as any number of parameterized
constructors.

I do not necessarily consider this to be overriding so much, so the
terminology is suspect.

-- 
Gregory A. Beamer
MVP; MCP: +I, SE, SD, DBA
************************************************
Think Outside the Box!
************************************************
"Samer" <samabutaa@hotmail.com> wrote in message
news:a2254096.0405181019.73d70a25@posting.google.com...
> I'm writing a class that derives from ServiceBase and it says in the
> documentation for the constructor of ServiceBase that if you override
> the base class constructor, you should explicitly call it in the
> constructor of your derived class.
>
> As far as I know a constructor cannot be overridden only overloaded,
> is this a mistake or have I been mislead.


Relevant Pages

  • Re: overides/loads usage
    ... #2 But why not always use overloading or shadowing rather than overriding? ... shadowing especially since to override requires the ... procedure in the derived class shadowing or overriding the new procedure ... will fire and then the constructor from class "B". ...
    (microsoft.public.dotnet.languages.vb)
  • ArrayList(ICollection) constructor & overriden ArrayList.AddRange().
    ... I'm encountering a very simple issue with ArrayList constructor ... and AddRange() method overriding. ... constructors versus virtual method calls usage? ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: Rationale behind constructor call chain... ( and comparison with C++)
    ... I think you mean class B and class A. If B extends A, then an instance of B is itself an instance of A. ... called within the A constructor, even if the overloaded function is B ... Set it after the super constructor is called. ... In you overriding methods, if it has not been set just call the super method and exit. ...
    (comp.lang.java.programmer)
  • Re: Overloading ctor doesnt work?
    ... > datetime is immutable so overriding the constructor doesn't change the ... Ahhh! ... Thanks a bunch, now this makes things much clearer. ...
    (comp.lang.python)
  • Re: Proposal: Default Parameters/Named Parameters
    ... its referenced assemblies changes means the burned-in defaults would be ... Anders' mentioned the possibility of object initialization syntax that may ... If you didn't want to expose your constructor parameters as properties ... I like this a lot (especially since it's avoids the overload resolution ...
    (microsoft.public.dotnet.framework.clr)