© 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
C#C
C#•2y ago•
21 replies
TahaA

✅ where constraint on interface method

Is it even possible? Like
public void RefuelCar<c>(c Car) where c : IUseGas.Refuel
public void RefuelCar<c>(c Car) where c : IUseGas.Refuel


Here the generic type is constrainted to where it implements an interface's method, whereas the name of the interface is
IUseGas
IUseGas
C# banner
C#Join
We are a programming server aimed at coders discussing everything related to C# (CSharp) and .NET.
61,871Members
Resources
Recent Announcements

Similar Threads

Was this page helpful?

Similar Threads

✅ Can i put constraint on ctor in interface
C#CC# / help
3y ago
Can't access interface method
C#CC# / help
2y ago
interface vs extension method vs method in class
C#CC# / help
3y ago
❔ Static interface methods
C#CC# / help
3y ago