This document lists useful C# code snippets for Visual Studio including snippets for Console.WriteLine, constructors, properties, classes, loops, conditionals, exceptions and more. To use a snippet, type its name and press Tab twice.
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0 ratings0% found this document useful (0 votes)
50 views2 pages
Ultimate C# Masterclass - Useful Code Snippets
This document lists useful C# code snippets for Visual Studio including snippets for Console.WriteLine, constructors, properties, classes, loops, conditionals, exceptions and more. To use a snippet, type its name and press Tab twice.
To use a code snippet, we must write it (for example, “cw”) and then press Tab twice.
Here are the most useful code snippets:
● cw - Creates a call to Console.WriteLine ● ctor - Creates a constructor for the containing class ● prop - Creates an auto-implemented property declaration ● propfull - Creates a property declaration with get and set accessors ● propg - Creates a read-only auto-implemented property with a private set accessor ● class - Creates a class declaration ● struct - Creates a struct declaration ● enum - Creates an enum declaration ● do - Creates a do-while loop ● while - Creates a while loop ● for - Creates a for loop ● foreach - Creates a foreach loop ● if - Creates an if block ● else - Creates an else block ● switch - Creates a switch block ● try - Creates a try-catch block ● tryf - Creates a try-catch-finally block ● indexer - Creates an indexer declaration ● equals - Creates a method declaration that overrides the Equals method defined in the Object class ● attribute - Creates a declaration for a class that derives from Attribute ● exception - Creates a declaration for a class that derives from Exception