2010-09-20 43 views
7

我正在尋找C#代碼片段的列表,這將使我們的工作速度更快Visual Studio 2010中有用的Visual Studio 2010的C#代碼智能感知列表網頁摘要

PS裏面。作爲擴展名,我在談論視覺工作室中的code snippets。 Ctrl + K,Ctrl + X,以訪問代碼片段......例如,我在屏幕上看到一個人在輸入'pi'並按下其他按鈕的位置。該段創造了這個對他來說:

private int _{namehere}; 
public int {namehere} { 
    get{ return _{namehere}; } 
    set{ _{namehere} = value; } 
} 
+1

更好的谷歌它 – anishMarokey 2010-09-20 14:34:58

+2

似乎這可能是一個體面的社區wiki – Wesley 2010-09-20 15:10:36

+0

我沒有downvote任何東西。 – 2010-09-20 15:26:03

回答

3

片段,這將使在VS2010「我」的工作速度更快,不一定會做出「你的」工作得更快。我使用各種各樣的片段來完成我經常重複的任務,或者對於那些我很少做的任務,如果沒有參考以前的工作或示例,我不記得如何做。我使用與DICOM和成像相關的片段。這對大多數人來說不會很有用。

我認爲最好的做法是創建自己的片段庫,這些片段將是您在代碼中常用的項目。請參閱您在問題中鏈接的頁面上的第一個鏈接,以瞭解如何創建自己的摘要。

還有幾個有用的代碼片段編輯器和創作者,如Snippet EditorSnippet Creator,可以幫助管理和修改您的代碼段。

具體來說,你指的是片斷,以下保存爲是.snippet文件並將其放置在「我的文檔\ Visual Studio 2010的\代碼段\的Visual C#\我的代碼段\」文件夾:

<?xml version="1.0" encoding="utf-8"?> 
<CodeSnippets xmlns="http://schemas.microsoft.com/VisualStudio/2005/CodeSnippet"> 
    <CodeSnippet Format="1.0.0"> 
    <Header> 
     <Title>Public Integer Property</Title> 
     <Author>md5sum</Author> 
     <Description>Creates a private integer member with a public integer property</Description> 
     <HelpUrl /> 
     <SnippetTypes /> 
     <Keywords /> 
     <Shortcut>pi</Shortcut> 
    </Header> 
    <Snippet> 
     <References /> 
     <Imports /> 
     <Declarations> 
     <Literal Editable="true"> 
      <ID>varName</ID> 
      <Type>int</Type> 
      <ToolTip>The name of the variable.</ToolTip> 
      <Default>VarName</Default> 
      <Function /> 
     </Literal> 
     </Declarations> 
     <Code Language="csharp" Kind="method decl" Delimiter="$"><![CDATA[private int _$varName$ 
    public int $varName$ 
    { 
     get 
     { 
      return _$varName$; 
     } 
     set 
     { 
      $varName$ = value; 
     } 
    }]]></Code> 
    </Snippet> 
    </CodeSnippet> 
</CodeSnippets> 
+1

感謝代碼編輯器 – 2010-09-20 15:31:45

+0

這是我使用的爲我所做的一切我的片段。 – 2010-09-20 15:37:17

+0

片段編輯器非常棒!謝謝 – 2012-02-23 21:23:42

相關問題