abstract and base class

  • Thread starter Thread starter JB
  • Start date Start date
J

JB

My problem:

I have an abstract class that implements an Interface:

abstract class ReportBase: IReport
{
..... Constructor and Code....
}

On a user control I try to have it's class derive from the
ReportBase base class:

public class sqlsample : System.Web.UI.UserControl,
ReportBase
{
..... Code.....
}

WHen I compile I get the following error on the user
control (on the line referencing ReportBase):

sqlsample.ascx.cs(18): 'ReportBase' : type in interface
list is not an interface

I thought that in C#, this is how I derive from a base.
the error message looks like it is expects ReportBase to
be an interface...

Is there a different way of referencing a base class in
ASP.NET? I cannot find any help on that message. Has
anyone ran into that problem before?

Thanks! JB.
 
A class can only inherit from ONE other class. It can implement as many
interfaces as it likes, but can only inherit from one class. Your class
definition includes inherits references to TWO classes,
System.Web.UI.UserControl, and ReportBase.

--
HTH,
Kevin Spencer
..Net Developer
Microsoft MVP
Big things are made up
of lots of little things.
 
Hi JB,
The reason why you are getting the message is because c# only allows single
inheritance, so you can only derive from one class (but you can implement
multiple interfaces).
Since sqlsample already derives from UserControl, any further type in your
declaration is expected to be an interface.

Regards
Claudio Perrone
 
The problem, if I'm not mistaken, is that you are actually trying to
derive from two bases: System.Web.UI.Control and ReportBase. In C#,
you can only derive from a single class. In the class declaration,
anything after the first class in the inheritance sequence must be an
interface. The error message is telling you that ReportBase isn't an
interface.

HTH

Bruce Johnson
http://www.ObjectSharp.com/Bruce
 
Back
Top