Reputation: 32202
I want to write a method that accepts a parameter that is a Frame. In pseudo c#
public void Foo(FrameworkElement and ISomeInterface p){
...
}
Is this possible? It would have to work with a class defined so
public class MyGrid : Grid, ISomeInterface {
}
where it is known that Grid is a subclass of FrameworkElement
Upvotes: 2
Views: 57
Reputation: 67928
You can create a generic method that enforces those constraints:
public void Foo<T>(T p)
where T : FrameworkElement, ISomeInterface
so here you're saying that the Type
of the object passed in needs to be a FrameworkElement
and implement ISomeInterface
.
Upvotes: 4