Hi There.
i am learning C# programing. when i was practicing method overriding concept i got below error.
please any body can help me to address this issue i would be grateful.
My Code:
i am learning C# programing. when i was practicing method overriding concept i got below error.
please any body can help me to address this issue i would be grateful.
My Code:
C#:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace PolyMorphism
{
public class PolyMorphism1
{
public int getPolyTotalCost(int intQty)
{
return intQty;
}
public virtual int getPolyTotalCost(int intQty , int intProduct)
{
return intQty * intProduct;
}
}
public class PolyMorphism2 : PolyMorphism1
{
public override int [COLOR=#ff0000]getPolyTotalCost[/COLOR](int intQty, int intProduct, int intPerProDiscount) // I am getting error this line...." No suitable method found to override "
{
return (getPolyTotalCost(intQty, intProduct) - intPerProDiscount);
}
}
}
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using PolyMorphism;
namespace ConsoleApplication1
{
class Program
{
static void Main(string[] args)
{
PolyMorphism1 Poly1 = new PolyMorphism1();
PolyMorphism2 Poly2 = new PolyMorphism2();
Console.WriteLine("Enter Product Price:");
int a = Convert.ToInt16(Console.ReadLine());
Console.WriteLine("Enter Product Quantity:");
int b = Convert.ToInt16(Console.ReadLine());
Console.WriteLine("Total is:" + Poly1.getPolyTotalCost(a, b));
Console.WriteLine("Enter Product Discount:");
int c = Convert.ToInt16(Console.ReadLine());
Console.WriteLine("The total after discount is");
Console.WriteLine(Poly2.getPolyTotalCost(a, b, c));
Console.ReadLine();
}
}
}