Code snippets for methods in Visual Studio

前端 未结 8 1522
青春惊慌失措
青春惊慌失措 2020-12-07 13:26

In Visual Studio I can type e.g.

for TAB TAB

and a code snippet pops in.

Are there built-in code

8条回答
  •  -上瘾入骨i
    2020-12-07 13:45

    Below are the steps I used to create a custom snippet for Visual Studio 2010, but the steps work for Visual Studio 2008.

    Create a new text file named method.snippet and paste the following:

    
    
        
            
    method method Code snippet for method Kevin Hogg Expansion
    methodname Method name MethodName() MethodNamePlaceholder

    Copy your file into the snippets folder in Windows Explorer:

    • Visual Studio 2010: C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC#\Snippets\1033\Visual C#
    • Visual Studio 2008: C:\Program Files (x86)\Microsoft Visual Studio 9.0\VC#\Snippets\1033\Visual C#

    Once you save your file, the snippets are automatically loaded, so you can now open Visual Studio and type:

    method
    

    *where is the Tab key on your keyboard.

    You should now see the following created, with the MethodNamePlaceholder highlighted so you can change the name.

    public void MethodNamePlaceholder()
    {
    
    }
    

提交回复
热议问题