Please help me! Can i somehow customize auto-generated code snippet displayed in overridden method body by default?
by default overridden method looks like
public override void Method(int A, object B)
{
base.Method(A, B);
}
i want to replace default code snippet with my own, e.g.
public override void Method(int A, object B)
{
if (A > 0)
{
// some code..
}
else
{
// some code..
}
}
EDIT
i have base class
public class BaseClass
{
public int Result {get;set;}
// This method depends on result
protected virtual void Method() {}
}
there is a lot of classes, that are derived from the BaseClass. All of them have to process Result property in Method() in same way. So, i want to place some code, wich shows how to use it. According to my idea when i type "override" and select "Method()" in intelisense list i get following code:
public class DerivedClass: BaseClass
{
public override void Method()
{
// u have to check result property
if(result > 0)
{
// if result is positive do some logic
}
}
}
instead of default code snippet
public class DerivedClass: BaseClass
{
public override void Method()
{
base.Method();
}
}
FINALLY
Using Template Method pattern is a good idea for such cases.
Thank you all for sharing your thoughts!