There are several ways to implement what you are talking about.
Assuming you have a structure like
MyTypeA : CLR_TypeA
{
public override ToString()
{
}
}
MyTypeB : CLR_TypeB
{
public override ToString()
{
}
}
Then it makes sense to want to have a base class, but you cannot. One of the methods that is mentioned in other answers is composition. However, in your case it is possible to create another static class
public static class ToStringHelpers
{
public static DoComplicatedStuff()
{
}
}
MyTypeA : CLR_TypeA
{
public override ToString()
{
DoComplicatedStuff();
}
}
MyTypeB : CLR_TypeB
{
public override ToString()
{
DoComplicatedStuff();
}
}
, , . , "DoComplicatedStuff()" , / .
, MI
MyBaseType : CLRType
{
public override void Execute(HttpContext context)
{
}
public void DoStuff()
{
}
}
MyTypeA : MyBaseType
{
public void MyTypeACustomMethod()
{
}
}
MyTypeB : MyBaseType
{
public void MyTypeBCustomMethod()
{
}
}