[Mono-dev] Re: Constructor implementation obligation via interface?
Kornél Pál
kornelpal at gmail.com
Wed May 24 10:30:46 EDT 2006
Constructors are declared in the class itself. Not in an interface or in
base classes. Constructors are non-virtual methods. As such you cannot force
constructor implementation.
Kornél
----- Original Message -----
From: "Ympostor" <ympostor at clix.pt>
To: <mono-devel-list at lists.ximian.com>
Sent: Wednesday, May 24, 2006 4:23 PM
Subject: [Mono-dev] Re: Constructor implementation obligation via interface?
> Martin Hinks escribió:
>> You can't force a constructor via an interface...
>>
>> Write an abstract class with the constructor definition that you want,
>> specify that the interface inherits the abstract class
>
> It seems an interface cannot inherit from a class. Example:
>
> public abstract class ExampleWithEmptyConstructor
> {
> public ExampleWithEmptyConstructor()
> {
> }
> }
>
> public interface IExample : ExampleWithEmptyConstructor
> {
>
> }
>
> This returns a compilation error: Error 1 Type
> 'ExampleWithEmptyConstructor' in interface list is not an interface.
>
> Regards
>
> --
>
> _______________________________________________
> Mono-devel-list mailing list
> Mono-devel-list at lists.ximian.com
> http://lists.ximian.com/mailman/listinfo/mono-devel-list
More information about the Mono-devel-list
mailing list