What Visual Studio provides for you, are the Code Snippets.
With this feature, you are able to create several different types of code snippets.
Within the scope of a class, when activating the Code Completion, you can filter all the snippets available.
One I use a lot is the ctor
which creates a constructor for the class.
For the implementation of a complete property, you can use the propfull
. That it will create the following implementation for you:
private int myVar;
public int MyProperty
{
get { return myVar; }
set { myVar = value; }
}
To use the Snippet, you can type it normally and after you press Tab on your keyboard.
There is no magic, something you will have to type in to be able to utilize the resources that accelerate development.
Another interesting resource that can help you a lot, is the Quick Actions, that can be triggered with the shortcut Ctrl+.
.
What do you mean by "keyboard"? It didn’t make any sense to me.
– user28595
I don’t want to implement the method or the interface by the mouse but by the keyboard.
– sYsTeM
It is not yet clear its objective. Implement where?
– user28595
Are you talking about the IDE? If so which would it be? Eclipse? Android Studio?
– Fernando Souza
Windows Forms C#
– sYsTeM
I classified by steps, first I want to put the methods of an interface "by some keyboard shortcut" in a class without interface. 2º I refer how I will implement a method of "writing and reading" to drop the get and set value automatically "by some keyboard shortcut". Are separate steps
– sYsTeM
You refer to the visual studio?
– user28595
Yeah, it’s by Visual Studio.
– sYsTeM
If you type "prop" and hit tab twice Visual Studio(2012>) automatically writes
public int MyProperty { get; set; }
, let theint
selected for you to write the type you want, with another tab it goes to the variable name. That’s what you want ?– LP. Gonçalves
Yes, how can I do now in the class that inherits the interface?
– sYsTeM
I did a lot of research, but I couldn’t find anything related via keyboard shortcut that works, other than the
CTRL + .
. There’s an option, but I couldn’t make it work.Visual Studio 2017 > "Ferramentas" > "Opções" > "Ambiente" > "Teclado"
, now in the field"Usar o novo atalho em:"
choosing"Editor de texto"
, in the field"Mostrar comandos que contenham:"
select"Projeto.ImplementarInterface"
. Add the shortcut keys you want and test. Adapted reference link– LP. Gonçalves