I am trying to associate C # generics with a class and the following interface:
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);
}
}
with an error
The best overloaded method match for 'Controls.WizardPage <T> .WizardPage (T)' has some invalid arguments
Am I doing something wrong or is it just not working?
source
share