[Mono-list] Keyword this or base expected(CS1018)

gennady wexler adyler@winisp.net
Sat, 21 Aug 2004 22:20:36 -0700


of course this wont compile, since you class needs to be deriving from a
class which we will consider a base that has a constructor that takes your
type of arguments:

so to correct the below should look like this:

 class MyBase {
     public MyBase (Glade.XML gxml, Database database) {
         // rest of your construction logic goes here
     }

 class MyClass : MyBase {
     public MyClass (Glade.XML gxml, Database database)
         : base(gxml, database) {
         // rest of your construction logic goes here
     }

hope this helps.

On 8/21/04 10:15 PM, "gennady wexler" <adyler@winisp.net> wrote:

> in constructor of your class:
> 
> class MyClass {
>     public MyClass(Glade.XML gxml, Database database)
>         : base(gxml, database) {
>         // rest of your construction logic goes here
>     }
> 
> you base class needs to be ready for the case if null objects were passed
> and react accordingly.
> 
> On 8/21/04 9:56 PM, "Rob Brown-Bayliss" <rbb@orcon.net.nz> wrote:
> 
>> 
>> OK, so how do I pass args to the base class?
>> 
>> I thought:
>> 
>> MyClass my_class = new MyClass(gxml, database);
>> 
>> would pass gxml and database to the base class of MyClass?
>> 
>>> This is wrong.
>>> 
>>> While calling the contructor, the gxml and database are undefined. If
>>> you be appropriate to call as:
>>> 
>>> public MyClass(): base(null, null)
>>> {
>>> ...
>>> }
>>> 
>>> or better still:
>>> 
>>> public MyClass(): base( (Glade.XML) null, (Database) null )
>>> {
>>> ...
>>> }
>>> 
>>> Use the latter option if there are more than one overloaded
>>> consturctor in the base class that can make up for BaseClass(null,
>>> null).
>>> 
>>> NB: I have assumed that Glade.XML is not enum.
>>> 
>>> 
>>> 
>>> Cheers,
>>> Gaurav Vaish
>>> http://gallery.mastergaurav.net
>>> -----------------------------------
>>> 
>>> 
>>> On Sun, 22 Aug 2004 16:19:03 +1200, Rob Brown-Bayliss <rbb@orcon.net.nz>
>>> wrote:
>>>> 
>>>> Why does this:
>>>> 
>>>> public MyClass() : base (Glade.XML gxml, Database database)
>>>> 
>>>> give me this error?
>>>> 
>>>> Keyword this or base expected(CS1018)
>> 
>> --
>> Rob Brown-Bayliss
>> 
>> ________________________________________________________________________
>> _______________________________________________
>> Mono-list maillist  -  Mono-list@lists.ximian.com
>> http://lists.ximian.com/mailman/listinfo/mono-list
> 
> 
> _______________________________________________
> Mono-list maillist  -  Mono-list@lists.ximian.com
> http://lists.ximian.com/mailman/listinfo/mono-list