Dev
Dev

Reputation: 1826

How to override a function in .NET 4.7.2 C# 7.3

I am trying to make a function overridable but I keep getting:

Severity Code Description Project File Line Suppression State Error CS8703 The modifier 'virtual' is not valid for this item in C# 7.3. Please use language version '8.0' or greater.

public interface IFruit
{

    protected virtual void Eat(IFork connectionModuleData);

}

public interface IApple:IFruit
{

    protected Override void Eat(IAppleFork connectionModuleData);

}

Upvotes: 0

Views: 183

Answers (1)

cly
cly

Reputation: 708

How about use generics instead?

public interface IFruit<TTool>
   where TTool:IFork
{
    void Eat(TTool connectionModuleData);
}

public interface IApple:IFruit<IAppleFork> // assuming IAppleFork is IFork
{
}

Upvotes: 1

Related Questions