class operation
{
public void add(int val1 , int val2)
{
int result;
result= val1+ val2;
return result;
}
}
class view : operation
{
public override in add(int val1 , int val2)
{
int result;
result = val1+val2;
return result;
}
}
Invalid token 'in' in class, struct, or interface member declaration
How can I remove this error from above code?
inis a reserved keyword in C#. You probably want:Also in order to be able to override some method in a derived class this method must be virtual in the base class:
In the
operationbase class you have declared theaddmethod with no return type and yet you are trying to return an integer.Also there’s no point in overriding a base method just to repeat the same code. You could simply invoke the base method in the overriden method:
or simply:
which would be equivalent because you are not modifying anything in this method.