Generates an interface for reference to a non-existent type and adds the interface members referenced from the initial code to it. The interface is declared in a new source code file.
The Declare Interface also declares interface members called from the initial code.
Available on the name of an interface if it does not exist.
Place the caret on a reference to non-existent interface.
The blinking cursor shows the caret's position at which the Code Provider is available.
Use the Ctrl + . or Ctrl + ~ shortcut to invoke the Code Actions Menu.
Select Declare | Declare Interface from the menu.
After execution, the Code Provider adds a new file to the project and declares the interface in it.
//Filename: IPerson.cs
public interface IPerson {
void SaveToDB();
int Age { get; set; }
}
You can configure where to place the newly-generated type declarations. The possible options are: Above the current type, Below the current type, or Create a new file. Open the Editor | <Language> | Code Actions | Code Actions Settings options page to change this option.