Reputation: 64205
I want something like this:
public static TTo JumpTo<TFrom, TTo>(this TFrom from_page)
where TTo : new() TFrom : new()
{
...
}
And I want to enforce that TFrom and TTo are both derived from a base type.
And I want to make this method as an extension method of TFrom type.
Is it possible ? And what's the correct syntax?
Upvotes: 1
Views: 146
Reputation: 17307
Put the keyword where
before each type.
public static TTo JumpTo<TFrom, TTo>(this TFrom from_page)
where TTo : SomeBaseType, new()
where TFrom : SomeOtherBaseType, new()
{
...
}
Upvotes: 10