Home > database >  I am getting following error in my c-sharp code. please give me idea how to fix it
I am getting following error in my c-sharp code. please give me idea how to fix it

Time:09-13

Getting Following Error in Polymorphism

I'm getting this error in my C# Code as I'm New to C-Sharp, So I'm Struggling to Fix this One.

Here's the Error Am Getting:

Error or Warning Here

CodePudding user response:

As the error message says, you need to use the new keyword if you want to replace the implementation from the parent class.

public new void animalSound()

CodePudding user response:

This is not an error. It is a warning. Using "new" keyword in method declaration as

public new void animalSound()

will silence the warning. But, it is better to understand what is going on. Refer to this Microsoft documentation to understand this warning as well as the difference between using "new" and "override" keywords in C# polymorphism.

  • Related