Search code examples
c#visual-studioshortcut

Is there a shortcut in VisualStudio to create a method?


Is there a shortcut in VisualStudio to create a method, like there is "prop, tab" for a property and "ctor, tab" for a constructor?


Solution

  • There is no Code snippet to create a method other than Main, but you can do the following.

    Type your to be method name, pass the parameters, once done you will notice a red underline at the beginning of method name. Click that (or click Ctrl + .), it will give you the option to create method like this:

    Screenshot of implementation

    This will generate a method like the following:

    private static void MySomeMethod(int a, string b)
    {
        throw new NotImplementedException();
    }