Abstract class implementing interface [modified]
-
There's an abstrat class in .NET
public abstract class CollectionBase : IList, ICollection, IEnumerable{...}
However, No definition or declaration ofIList
's functions are found inCollectionBase
. How could this ever happen? If it's an abstract class, it's allowed to not implement its interface? Thanks everybody:-D -
There's an abstrat class in .NET
public abstract class CollectionBase : IList, ICollection, IEnumerable{...}
However, No definition or declaration ofIList
's functions are found inCollectionBase
. How could this ever happen? If it's an abstract class, it's allowed to not implement its interface? Thanks everybody:-DYes, only concrete classes must.
-
Yes, only concrete classes must.
Thanks, but why won't the following code compile?
using System; using System.Collections.Generic; using System.Text; namespace ConsoleApplication1 { interface A{ void A(); } abstract class B : A { // public abstract void A(); } }
I got an error! The compiler says I should implement A.A() in abstract class B. -
Thanks, but why won't the following code compile?
using System; using System.Collections.Generic; using System.Text; namespace ConsoleApplication1 { interface A{ void A(); } abstract class B : A { // public abstract void A(); } }
I got an error! The compiler says I should implement A.A() in abstract class B.That's exactly the same concept - you're not declaring a concrete class anywhere. If you add
class C : B
{
// No implementation of A here as well
}then you'll get a compiler error.
Regards, mav -- Black holes are the places where God divided by 0...
-
That's exactly the same concept - you're not declaring a concrete class anywhere. If you add
class C : B
{
// No implementation of A here as well
}then you'll get a compiler error.
Regards, mav -- Black holes are the places where God divided by 0...
-
Thanks, but why won't the following code compile?
using System; using System.Collections.Generic; using System.Text; namespace ConsoleApplication1 { interface A{ void A(); } abstract class B : A { // public abstract void A(); } }
I got an error! The compiler says I should implement A.A() in abstract class B.My earlier answer wasn't quite as correct as I would have preferred. :-D You need the
abstract
stub, but it's still not an implementation.