VB.NET 中有自动属性的代码片段吗?

发布于 2024-10-11 03:15:55 字数 85 浏览 0 评论 0原文

在 Visual Studio 2010 中,对于 VB.NET,“属性”+ Tab + Tab 插入完整的属性实现。是否还有另一个用于插入自动属性的片段?

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

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

宛菡 2024-10-18 03:15:55

只需将其放入名为 C:\Users\\Documents\Visual Studio 2010\Code Snippets\Visual Basic\My Code Snippets\DefaultProperty.snippet 的文件中,然后重新启动 VS...或者将其放入该文件中但不在该目录中,然后在 VS 中单击“工具”、“代码片段管理器”,然后选择“Visual Basic”作为语言...单击“导入”按钮。选择新文件,然后选择顶部文件夹“我的片段”。现在,在 IDE 中只需键入 PropDefAuto 和 tab tab。请随意修改该文件。

<?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>

Just put this in a file called C:\Users\\Documents\Visual Studio 2010\Code Snippets\Visual Basic\My Code Snippets\DefaultProperty.snippet and restart VS... or put it in that file but not in that dir, then in VS click Tools, Code Snippets Manager, and Select Visual Basic as the language... the click on the Import button. Select your new file, and then choose the top folder "My Snippets". Now in the IDE just type PropDefAuto and tab tab. Feel free to modify the file.

<?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>
辞别 2024-10-18 03:15:55

目前在 VB 中最接近的就是打字。

Property Name as string

您可以在 此博客,作者:The Gu

The closest you can currently get in VB is typing out

Property Name as string

You can find more information in this blog post by The Gu

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文