2

In Visual Studio 2010, for VB.NET, the "Property" + Tab + Tab inserts a full property implementation. Is there another snippet for inserting an autoproperty?

4

2 に答える 2

3

これをC:\ Users \\ Documents \ Visual Studio 2010 \ Code Snippets \ Visual Basic \ My Code Snippets \DefaultProperty.snippetというファイルに入れてVS...を再起動するか、そのファイルに入れて、そのディレクトリには入れないでください。次に、VSで[ツール]、[コードスニペットマネージャー]の順にクリックし、言語として[VisualBasic]を選択します...[インポート]ボタンをクリックします。新しいファイルを選択してから、一番上のフォルダ「マイスニペット」を選択します。IDEで、PropDefAutoと入力してタブタブを入力します。ファイルを自由に変更してください。

<?xml version="1.0" encoding="UTF-8"?>
<CodeSnippets xmlns="http://schemas.microsoft.com/VisualStudio/2005/CodeSnippet">
  <CodeSnippet Format="1.0.0">
    <Header>
      <Title>Define a Auto-Implemented Default Property</Title>
      <Author>Some Guy On SO</Author>
      <Description>Defines an Auto-Implemented default property or index property.</Description>
      <Keywords>
          <Keyword>PropAuto</Keyword>
      </Keywords>
      <Shortcut>PropDefAuto</Shortcut>
    </Header>
    <Snippet>
      <Imports>
        <Import>
          <Namespace>System</Namespace>
        </Import>
      </Imports>
      <Declarations>
        <Literal>
          <ID>propertyName</ID>
          <Type>
          </Type>
          <ToolTip>Rename to descriptive name for the property.</ToolTip>
          <Default>PropertyName</Default>
        </Literal>
        <Literal>
          <ID>indexType</ID>
          <Type>
          </Type>
          <ToolTip>Replace with the type of the index</ToolTip>
          <Default>Integer</Default>
        </Literal>
        <Literal>
          <ID>propertyType</ID>
          <Type>
          </Type>
          <ToolTip>Replace with the type returned by the property.</ToolTip>
          <Default>String</Default>
        </Literal>
        <Literal>
          <ID>IndexIsValid</ID>
          <Type>Boolean</Type>
          <ToolTip>Replace with an expression to test if index is valid.</ToolTip>
          <Default>True</Default>
        </Literal>
      </Declarations>
      <Code Language="VB" Kind="method decl"><![CDATA[Public Property $propertyName$ As $PropertyType$
      ]]></Code>
    </Snippet>
  </CodeSnippet>
</CodeSnippets>
于 2011-01-07T23:49:27.750 に答える
0

あなたが現在VBで得ることができる最も近いものはタイプアウトです

Property Name as string

詳細については、The Gu によるこのブログ投稿を参照してください。

于 2011-01-07T23:34:22.430 に答える