Declare Method (abstract)
In This Article
Generates an abstract method for the selected method call with appropriate parameters. Activates Text Fields for the method parameters and drops a marker onto the initial method call.
#Availability
Available from the context menu or via shortcuts:
- when the caret is on a statement calling an undeclared method. The caret should be on the method name.
Note
The refactoring is only available in an abstract class.
#Examples
abstract class ClassBase
{
private void MyMethod()
{
int i = 10;
string s = "Test";
string str = │TestMethod(i, s);
}
}
MustInherit Class TestClass
Private Sub TestMethod()
Dim a As Integer = 15
Dim str As String = "Test"│MyMethod(a, str)
End Sub
End Class
Result:
abstract class ClassBase
{
protected abstract string TestMethod(int │i, string s);
private void MyMethod()
{
int i = 10;
string s = "Test";
string str = TestMethod(i, s);
}
}
MustInherit Class TestClass
Protected MustOverride Sub MyMethod(ByVal │a As Integer, ByVal str As String)
Private Sub TestMethod()
Dim a As Integer = 15
Dim str As String = "Test"
MyMethod(a, str)
End Sub
End Class