Question regarding common class
- by Rocky Singh
I have following two classes:
public class A : System.Web.UI.WebControls.Button
{
public virtual string X
{
get
{
object obj = ViewState["X"];
if (obj != null) return (string)obj;
return null;
}
set
{
ViewState["X"] = value;
}
}
protected override void OnLoad(EventArgs e)
{
X=2;
}
}
and
public class B : System.Web.UI.WebControls.TextBox {
public virtual string X
{
get
{
object obj = ViewState["X"];
if (obj != null) return (string)obj;
return null;
}
set
{
ViewState["X"] = value;
}
}
protected override void OnLoad(EventArgs e)
{
X=2;
}
}
As you must be seeing the class A and B have exactly the same code , my question is how can I make a common class for it and use these two classes.