I am attempting to bind c# generics to a class and an interface like this:
public class WizardPage<T> where T : UserControl, IWizardControl
{
private T page;
public WizardPage( T page ) {
this.page = page;
}
}
And use it with this:
public class MyControl : UserControl, IWizardControl {
//...
}
Somehow C# doesn't seem to be able to decide that MyControl is a proper instance of T as
public class Wizard<T> where T : UserControl, IWizardControl {
private WizardPage<T> Page1;
public Wizard( MyControl control ) {
this.Page1 = new WizardPage(control);
}
}
fails with error
The best overloaded method match for 'Controls.WizardPage<T>.WizardPage(T)' has some invalid arguments
Am I doing something wrong or is this just not going to work?