Skip to content

Instantly share code, notes, and snippets.

@jerviscui
Last active May 26, 2024 23:10
Show Gist options
  • Select an option

  • Save jerviscui/4af937529f65b4d5eb27cbeff677efda to your computer and use it in GitHub Desktop.

Select an option

Save jerviscui/4af937529f65b4d5eb27cbeff677efda to your computer and use it in GitHub Desktop.
C# useful snippets
安装到目录:
C:\Users\xxx\Documents\Visual Studio 2019\Code Snippets\Visual C#\My Code Snippets
<?xml version="1.0" encoding="utf-8" ?>
<CodeSnippets xmlns="http://schemas.microsoft.com/VisualStudio/2005/CodeSnippet">
<CodeSnippet Format="1.0.0">
<Header>
<Title>cast</Title>
<Shortcut>cast</Shortcut>
<Description>Code snippet for cast statement</Description>
<Author>Jervis</Author>
<SnippetTypes>
<SnippetType>SurroundsWith</SnippetType>
</SnippetTypes>
</Header>
<Snippet>
<Declarations>
<Literal>
<ID>type</ID>
<ToolTip>Cast to type</ToolTip>
<Default>object</Default>
</Literal>
</Declarations>
<Code Language="csharp"><![CDATA[($type$)($selected$)$end$]]>
</Code>
</Snippet>
</CodeSnippet>
</CodeSnippets>
<?xml version="1.0" encoding="utf-8"?>
<CodeSnippets xmlns="http://schemas.microsoft.com/VisualStudio/2005/CodeSnippet">
<CodeSnippet Format="1.0.0">
<Header>
<Title>propps</Title>
<Shortcut>propps</Shortcut>
<Description>带有“get”访问器和受保护“set”访问器的自动实现属性的代码片段
语言版本: C# 3.0 或更高版本</Description>
<Author>Microsoft Corporation</Author>
<SnippetTypes>
<SnippetType>Expansion</SnippetType>
</SnippetTypes>
</Header>
<Snippet>
<Declarations>
<Literal>
<ID>type</ID>
<ToolTip>属性类型</ToolTip>
<Default>int</Default>
</Literal>
<Literal>
<ID>property</ID>
<ToolTip>属性名</ToolTip>
<Default>MyProperty</Default>
</Literal>
</Declarations>
<Code Language="csharp"><![CDATA[public $type$ $property$ { get; protected set; }$end$]]>
</Code>
</Snippet>
</CodeSnippet>
</CodeSnippets>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment