Reputation: 53
I have created a simple interface with the below code
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace DesignPattern_FactoryPattern
{
interface Shape
{
void drawshape();
}
}
Then, I have created another class with the below code
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace DesignPattern_FactoryPattern
{
class Square : Shape
{
public override void drawshape()
{
Console.WriteLine("Shape is Square");
}
}
}
I got the following error:
No suitable method found to be override.
Could you please help me?
Upvotes: 1
Views: 4441
Reputation: 2501
So you have:
Shape
Square
that implements the Shape
interfaceIn that case, you need to drop the word override
. The drawShape
method in your Square
class is the implementation of the method defined in the interface.
Let's say you had a base class named Shape
and you had the Square
class inherits from Shape
. That is a case where the drawShape
method would override
the method of the same name in the base class.
Upvotes: 4