This is a collection of the C# code snippets I use in Visual Studio for C# coding. If you're unfamiliar with using code snippets in Visual Studio, refer to this document for more information https://docs.microsoft.com/en-us/visualstudio/ide/code-snippets
The snippets are grouped into the directories in this repository based on what they perform.
Directory | Description |
---|---|
/expression-bodied-properties |
Snippets for quickly creating expression bodied properties. There is a snippet for each data type and a generic one. |
/fields |
Snippets for quickly creating fields. There is a snippet for each data type and a generic one. |
/full-properties |
Snippets for quickly creating public properties with a private backing field. There is a snippet for each data type and a generic one. |
/properties |
Snippets for quickly creating properties. There is a snippet for each data type. |
In order to use these code snippets, you first need to download them. The easiest way is to just clone this repository
git clone https://github.com/manbeardgames/csharp-code-snippets.git
Next, locate and open the code snippet directory for the version of visual studio you are using.
Version | Location |
---|---|
Visual Studio 2017 | %userprofile%\Documents\Visual Studio 2017\Code Snippets\Visual C#\My Code Snippets\ |
Visual Studio 2019 | %userprofile%\Documents\Visual Studio 2019\Code Snippets\Visual C#\My Code Snippets\ |
Then just copy the snippet you would like to use from the repo to the My Code Snippets directory.
You can find the syntax to use for each code snippet in the README.md file located inside of each of the directories in this repository.