473,387 Members | 1,882 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

abstract and base class

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.


Nov 18 '05 #1
3 1259
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.

"JB" <an*******@discussions.microsoft.com> wrote in message
news:01****************************@phx.gbl...
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.

Nov 18 '05 #2
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

"JB" <an*******@discussions.microsoft.com> wrote in message
news:01****************************@phx.gbl...
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.

Nov 18 '05 #3
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

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Nov 18 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Dave Veeneman | last post by:
Is is legal to declare abstract members in non-abstract classes? How about non-abstract members in abstract classes? I am writing a base class with three derived classes. The base class will...
4
by: Chuck Bowling | last post by:
I am using CodeDOM to generate source files. The classes being generated have a const string member. This member is referenced in an abstract base class but declared in the inheriting class. I...
6
by: Dan Sikorsky | last post by:
If we were to define all abstract methods in an abstract class, thereby making that class non-abstract, and then override the heretofore 'abstract' methods in a derived class, wouldn't that remove...
18
by: Bradley | last post by:
I'm trying to determine if there's a general rule for when an Interface should used vs. an Abstract Class. Is there any design advantage to using one or the other? Brad
9
by: Sean Kirkpatrick | last post by:
To my eye, there doesn't seem to be a whole lot of difference between the two of them from a functional point of view. Can someone give me a good explanation of why one vs the other? Sean
17
by: baibaichen | last post by:
i have written some code to verify how to disable slicing copy according C++ Gotchas item 30 the follow is my class hierarchy, and note that B is abstract class!! class B { public: explicit...
7
by: jason | last post by:
In the microsoft starter kit Time Tracker application, the data access layer code consist of three cs files. DataAccessHelper.cs DataAcess.cs SQLDataAccessLayer.cs DataAcccessHelper appears...
0
by: mailforpr | last post by:
Hi. Let me introduce an iterator to you, the so-called "Abstract Iterator" I developed the other day. I actually have no idea if there's another "Abstract Iterator" out there, as I have never...
0
by: emin.shopper | last post by:
I had a need recently to check if my subclasses properly implemented the desired interface and wished that I could use something like an abstract base class in python. After reading up on metaclass...
4
by: David Zha0 | last post by:
Hi, "when we call a virtual method, the runtime will check the instance who called the method and then choose the suitable override method, this may causes the performance drop down", is this...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.