How to implement methods and classes by some keyboard shortcut in visual studio?

Asked

Viewed 1,670 times

4

I need to implement methods and classes "keyboard" to get a value automatically.

1: Implement UI methods in the Home class:

class Inicio : Interface
{

}

2: Set and Get automatically:

private static RichTextBox rtb
{
     Get { return; }
     Set { value = value; }
}
  • What do you mean by "keyboard"? It didn’t make any sense to me.

  • I don’t want to implement the method or the interface by the mouse but by the keyboard.

  • It is not yet clear its objective. Implement where?

  • Are you talking about the IDE? If so which would it be? Eclipse? Android Studio?

  • Windows Forms C#

  • 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

  • 1

    You refer to the visual studio?

  • Yeah, it’s by Visual Studio.

  • 1

    If you type "prop" and hit tab twice Visual Studio(2012>) automatically writes public int MyProperty { get; set; }, let the int selected for you to write the type you want, with another tab it goes to the variable name. That’s what you want ?

  • Yes, how can I do now in the class that inherits the interface?

  • 1

    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

Show 6 more comments

1 answer

6


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. inserir a descrição da imagem aqui

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+..

inserir a descrição da imagem aqui

Browser other questions tagged

You are not signed in. Login or sign up in order to post.