© 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
C#C
C#•2y ago•
25 replies
tin

Using a default implementation on an interface

If I have an interface
interface IAttack<T> {
  T GetAttack();
}
interface IAttack<T> {
  T GetAttack();
}

And I now want to have a specialized interface
interface IUpgradableAttack<T> : IAttack<T>{
  int level {get; set;}
  T GetAttack(int level);
}
interface IUpgradableAttack<T> : IAttack<T>{
  int level {get; set;}
  T GetAttack(int level);
}

Can I somehow use the default implementation
GetAttack(){GetAttack(level)}
GetAttack(){GetAttack(level)}
to implement
IAttack
IAttack
for thingss that are implementing
IUpgradableAttack
IUpgradableAttack
?
C# banner
C#Join
We are a programming server aimed at coders discussing everything related to C# (CSharp) and .NET.
61,871Members
Resources

Similar Threads

Was this page helpful?
Recent Announcements

Similar Threads

✅ Confusion over defining a default implementation on an interface
C#CC# / help
3y ago
❔ Default implementation of a `static abstract` base interface member in derived interface
C#CC# / help
3y ago
✅ Explicit interface implementation
C#CC# / help
17mo ago
❔ Target runtime doesn't support default interface implementation.
C#CC# / help
4y ago