Is it possible to apply an extension method to an interface? (C# question)

That is for example to achieve the following:

  1. create an ITopology interface

  2. create an extension method for this interface (e.g. public static int CountNodes(this ITopology topologyIf) )

  3. then when creating a class (e.g. MyGraph) which implements ITopology, then it would automatically have the Count Nodes extension.

This way the classes implementing the interface would not have to have a set class name to align with what was defined in the extension method.

Edit
Report