Purpose
This Code Provider adds a member to an interface implemented by the current class. Use this Code Provider to make the member obligatory for all interface implementations.
Availability
Available when the caret is on a non-overridden member, assuming the class implements one or more interfaces.
Usage
Place the caret on a member name in its declaration.
Note
The blinking cursor shows the caret’s position at which the Code Provider is available.
interface IPerson {
string FullName { get; set; }
}
class Customer : IPerson {
public string FullName { get; set; }
public string MobilePhone│ { get; set; }
}
Interface IPerson
Property FullName() As String
End Interface
Class Customer
Implements IPerson
Public Property FullName() As String Implements IPerson.FullName
Public Property │MobilePhone() As String
End Class
- Press the Ctrl + . or Ctrl + ~ shortcut to invoke the Code Actions menu.
- Select Add to <Interface Name> Interface from the menu. In this case, the menu item will be Add to IPerson Interface.
After execution, the Code Provider adds the required member to the interface.
interface IPerson {
string MobilePhone { get; set; }
string FullName { get; set; }
}
class Customer : IPerson {
public string FullName { get; set; }
public string MobilePhone { get; set; }
}
Interface IPerson
Property MobilePhone As String
Property FullName() As String
End Interface
Class Customer
Implements IPerson
Public Property FullName() As String Implements IPerson.FullName
Public Property MobilePhone() As String Implements IPerson.MobilePhone
End Class