Re: Calling the base class constructor

Tech-Archive recommends: Speed Up your PC by fixing your registry

From: Jon Skeet [C# MVP] (skeet_at_pobox.com)
Date: 05/25/04


Date: Tue, 25 May 2004 13:06:43 +0100

Jo Vermeulen <jo@lumumba.luc.ac.be> wrote:
> I was wondering how I could call the base class constructor from a derived
> class constructor. In Java I could do something like
>
> super(parameter);
>
> I tried
>
> base(parameter);
>
> in C# but it doesn't compile. Any ideas?

You do base (parameter) but in a different place:

public Derived() : base (...)
{
}

See http://www.pobox.com/~skeet/csharp/constructors.html for more
information.

-- 
Jon Skeet - <skeet@pobox.com>
http://www.pobox.com/~skeet
If replying to the group, please do not mail me too


Relevant Pages

  • Re: Calling the base class constructor
    ... >> class constructor. ... In Java I could do something like ... This would give you the freedom to do parameter processing before calling ... Freeware Tools, Games and Humour ...
    (microsoft.public.dotnet.languages.csharp)
  • C# Constructors
    ... I am very new to C# but have worked with Java for ... documentation is how to call the superclass/based on class constructor ... it the base class properties are not used. ... in the InitializeComponent method or would it go in the Constructor? ...
    (microsoft.public.dotnet.languages.csharp)
  • Calling the base class constructor
    ... I was wondering how I could call the base class constructor from a derived ... In Java I could do something like ... Student Computer Science at the tUL ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: String.Format()
    ... No, that doesn't compile. ... > Eventhough a method is static you can access that method with its instance, ... this is one of the flaws in Java). ... If replying to the group, please do not mail me too ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: Calling Constructor conditionally
    ... Karthik D V wrote: ... class constructor. ... You'd have to have a static method which determined ... If replying to the group, please do not mail me too ...
    (microsoft.public.dotnet.languages.csharp)