Reputation: 21
im trying to create a an mvc framework to define the workflow of a project im working on. I created the view and controller classes and was trying to have the ui controller class be generic in order to have a type of uiview assigned to it when inheriting from ui controller:
UIView class
public class UIView
{
}
UIController class
public class UIController<T> where T : UIView
{
}
Implementation of UIView class
public class UIMenuView : UIView
{
}
Implementation of UIController class with UI Menu View
public class MenuController : UIController<UIMenuView>
{
}
Workflow implementation
void main()
{
var menuController = new MenuController();
SetController(menuController as UIController<UIView>);
}
public void SetController(UIController<UIView> controller, bool asRoot = false)
{
}
The problem is im getting the following error while trying to set the controller:
Cannot convert type 'MenuController' to 'UI.UIController<UI.UIView>' via a reference conversion, boxing conversion, unboxing conversion, wrapping conversion, or null type conversion [Assembly-CSharp]
Does anybody know what im doing wrong here? Thanks!
Upvotes: 0
Views: 39
Reputation: 3018
Following picture shows your inheritance hierarchy. Your casting menuController as UIController<UIView>
is what described with red arrow which is wrong.
Upvotes: 1