I have the following scenario:
IShape
defines method Draw
. Circle
implements IShape
and the method Draw
. Rectangle
implements IShape
and the method Draw
. Square
extends Rectangle
and overrides the method Draw
. I wrote the code as following for the above scenario:
class Program
{
static void Main(string[] args) { }
}
public interface IShape
{
void Draw();
}
public class Circle : IShape
{
public void Draw()
{
throw new NotImplementedException();
}
}
public class Rectangle : IShape
{
public void Draw()
{
throw new NotImplementedException();
}
}
public class Square : Rectangle
{
public virtual void Draw()
{
throw new NotImplementedException();
}
}
I am unable to get the last scenario which is class Square extends Rectangle and overrides the method Draw
.
Any help?
Rectangle.Draw virtual, Square.Draw override
public class Rectangle : IShape
{
public virtual void Draw()
{
throw new NotImplementedException();
}
}
public class Square : Rectangle
{
public override void Draw()
{
throw new NotImplementedException();
}
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.