1、打開代碼管理器
2、打開后就可以看到如下圖所示
3、復制粘貼該路徑,轉到該文件夾下
新加一個txt文件,把下面的文本復制粘貼
<?xml version="1.0" encoding="utf-8"?><CodeSnippets xmlns="http://schemas.microsoft.com/VisualStudio/2005/CodeSnippet"> <CodeSnippet Format="1.0.0"> <Header> <Title>ck</Title> <Shortcut>ck</Shortcut> <Description>Console.ReadKey 的代碼片段</Description> <Author>jinglingzi</Author> <SnippetTypes> <SnippetType>Expansion</SnippetType> </SnippetTypes> </Header> <Snippet> <Declarations> <Literal Editable="false"> <ID>SystemConsole</ID> <Function>SimpleTypeName(global::System.Console)</Function> </Literal> </Declarations> <Code Language="csharp"><![CDATA[$SystemConsole$.ReadKey();$end$]]> </Code> </Snippet> </CodeSnippet></CodeSnippets>
把文件的后綴名改為 .snippet.
4、你在寫代碼的地方,ck 然后兩下tab鍵,console.readkey就出來了。
技巧:
5、<Code Language="csharp"><![CDATA[$SystemConsole$.ReadKey();$end$]]>
這行代碼中的,$end$,是光標停止的位置。
6、我其實也不會怎么寫代碼片段,就是把cw的代碼片段復制粘貼,大膽修改后成功的。
愿大家的學習一路順風。
新聞熱點
疑難解答