Just know, type prop, and then press two times the TAB key to generate the automatic property code.
Having nothing to do today, I sorted out other quick ways to add code snippets in Visual Studio.
1. Automatic Properties
Type prop, and then press two times the TAB key to generate the automatic property code.
public int MyProperty {get; set;}
Through the experiment found that input pr,pro,proc, and then press two times the TAB key, the same will generate automatic property code snippets.
2.class
Type class, and then press the TAB key two times to generate the definition code.
Class MyClass
{
}
3.interface
Type interface, and then press two times the TAB key to generate the interface definition code.
Interface IInterface
{
}
4.struct
Type struct, and then press two times the TAB key to generate the structure definition code.
struct mystruct
{
}
5.for
Type for, and then press two times the TAB key to generate the for loop code.
for (int i = 0; i < length; i++)
{
}
6.foreach
Type foreach, and then press the TAB key two times to generate the Foreach Loop code.
foreach (var item in collection)
{
}
7.while
Typing while, and then pressing the TAB key two times, generates a while loop code.
while (true)
{
}
8.do-while
Typing do, and then pressing the TAB key two times, generates Do-while loop code.
Do
{
} (TRUE);
10.try-catch
Typing a try, and then pressing the TAB key two times, generates exception handling code.
Try
{
}
catch (Exception)
{
throw
}
11.if statement
Type if, and then press two times the TAB key to generate the conditional statement code.
if (true)
{
}
12.enum
Type an enum, and then press the TAB key two times to generate an enumeration definition code.
Enum MyEnum
{
}
13.namespace
Type namespace, and then press two times the TAB key to generate the namespace code.
Namespace MyNamespace
{
}
14.switch
The branch code is generated by typing the switch and then pressing the TAB key two times.
Switch (switch_on)
{
default:
Exception
Type exception, and then press the TAB key two times to generate the following code.
[Global::system.serializable]
public class Myexception:exception
{public
myexception () {} public
MyException (String message): Base ( Message] {} public
MyException (string message, Exception inner): base (message, inner) {}
protected Myexc Eption (
System.Runtime.Serialization.SerializationInfo info,
System.Runtime.Serialization.StreamingContext context): Base (info, context) {}
}
16 Dependent Properties
Type propdb, and then press two times the TAB key to generate the dependency property definition code.