Is it possible to pass in an object reference to a method signature for classes that share the same base class? i.e., simplified:
public class ClassA : System.Web.UI.Control
public class ClassB : System.Web.UI.Control
In Page:
private void SetCurrentView(ref Control ctrl)
{
ctrl.Visible = true;
}
protected void Page_Load(object sender, System.EventArgs e)
{
aClass = new ClassA();
bClass = new ClassB();
SetCurrentView(ref aClass);
SetCurrentView(ref bClass);
}
Obviously, as is, this does not work, and casting it in the method call would not be an assignable reference. Thoughts?
No, but you do not need
refhere anyway.To set the visibility, the following does exactly what you need: