Error with partial classes with ineherited class

R

Rotsey

Hi,

I have the following classes and am getting an error
"Projects does not implment inherited abstract member on Insert()"

Only the essential code is shown

public class DCBase
{
public abstract int Insert();
}

public partial class Projects : DCBase
{
//some code here
public int InsertBase()
{
}
}

public partial class Projects : DCBase
{
public int Insert()
{
InsertBase();
}
}


Please assist.
rotsey
 
J

Jon Skeet [C# MVP]

I have the following classes and am getting an error
"Projects does not implment inherited abstract member on Insert()"

Only the essential code is shown

To get this to compile, I had to:

1) Make DCBase abstract
2) Add return statements
3) Use the "override" modifier on the implementation of Insert

It then compiled fine.

If that doesn't help, please post a short but complete program that
demonstrates your problem.

Jon
 
R

Rotsey

Thanks Jon

It was the "override" keyword I missed.

I didn't think it was needed in that instance
 
J

Jon Skeet [C# MVP]

It was the "override" keyword I missed.

I didn't think it was needed in that instance

What error message did you get? When I remove the override modifier, I
get these error messages:

Projects2.cs(3,16): warning CS0114: 'Projects.Insert()' hides
inherited member
'DCBase.Insert()'. To make the current member override that
implementation, add the override keyword. Otherwise add the
new keyword.
DCBase.cs(3,25): (Location of symbol related to previous warning)
Projects1.cs(1,22): error CS0534: 'Projects' does not implement
inherited
abstract member 'DCBase.Insert()'
Projects2.cs(1,22): (Location of symbol related to previous error)
DCBase.cs(3,25): (Location of symbol related to previous error)

Did you not get the first error message? That makes the remedy
reasonably clear IMO.

Jon
 
I

Ignacio Machin \( .NET/ C# MVP \)

Hi,


It would had been helpful if you had posted the warning the compiler was
giving you in the first place.
 

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

Top