abstract and base class

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.
 
K

Kevin Spencer

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.
 
C

Claudio Perrone

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
 
B

BruceJohnson

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,787
Messages
2,569,629
Members
45,330
Latest member
AlvaStingl

Latest Threads

Top