I have this:
public class MyClass<T>: IView
{
public View View()
{
return this;
}
public void Render(ViewContext viewContext, System.IO.TextWriter writer)
{
// We should cycle though all supported controls and generate HTML for them.
// What about the validation binding?
typeof(T).GetFields().ToList<FieldInfo>().ForEach(x => writer.WriteLine(x.FieldType + " is called " + x.Name + "</br>"));
}
}
I get an error that it cannot implicitly cast this to a View. When I attempt a cast it fails. Is there any way to do this? Why does it fail?
EDIT: View implementation added. I trimmed too much out of the class. I apologize for not posting enough.
MyClass<T>instances are not convertible toView. They are only convertible toIView. If you want to inherit fromViewclass, you should just do that. Implementing a similarly named interface doesn’t magically cause the class to inherit from the base type you need: