Original URL: http://blog.csdn.net/yl2isoft/article/details/9735527
I used to only know that, typing prop, and then pressing the TAB key two times, generates an automatic property code.
Today I have nothing to do, just sort of. Other ways to quickly add code snippets in Visual Studio.
1. Automatic attributes
Typing prop and pressing the TAB key two times generates an automatic property code.
[CSharp]View Plaincopy
- public int MyProperty { get; set;}
Through the experiment found, input pr,pro,proc, and then press two times TAB key, will also generate automatic attribute code segment.
2.class
Typing class, and then pressing the TAB key two times, results in the definition code.
[CSharp]View Plaincopy
- Class MyClass
- {
- }
3.interface
Typing interface and pressing the TAB key two times will generate the interface definition code.
[CSharp]View Plaincopy
- Interface IInterface
- {
- }
4.struct
Type a struct, and then press two tab to generate the struct definition code.
[CSharp]View Plaincopy
- struct MYSTRUCT
- {
- }
5.for
Type for, and then press the TAB key two times to generate a for loop code.
[CSharp]View Plaincopy
- for (int i = 0; i < length; i++)
- {
- }
6.foreach
Typing foreach and pressing the TAB key two times generates a foreach Loop code.
[CSharp]View Plaincopy
- foreach (var item in Collection)
- {
- }
7.while
Typing while, and then pressing the TAB key two times, generates a while loop code.
[CSharp]View Plaincopy
- while (true)
- {
- }
8.do-while
Typing do, and then pressing the TAB key two times, generates the Do-while loop code.
[CSharp]View Plaincopy
- Do
- {
- } while (true);
10.try-catch
Typing the try, and then pressing the TAB key two times, generates exception handling code.
[CSharp]View Plaincopy
- Try
- {
- }
- catch (Exception)
- {
- throw;
- }
11.if statements
Typing if, and then pressing the TAB key two times, generates the conditional statement code.
[CSharp]View Plaincopy
- if (true)
- {
- }
12.enum
Typing an enum and pressing the TAB key two times will generate the enumeration definition code.
[CSharp]View Plaincopy
- Enum MyEnum
- {
- }
13.namespace
Typing namespace, and then pressing the TAB key two times, generates a namespace code.
[CSharp]View Plaincopy
- Namespace MyNamespace
- {
- }
14.switch
Typing switch and pressing the TAB key two times will generate the branch code.
[CSharp]View Plaincopy
- Switch (switch_on)
- {
- Default:
- }
Exception
Typing exception and pressing the TAB key two times will generate the following code.
[CSharp]View Plaincopy
- [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 MyException (
- System.Runtime.Serialization.SerializationInfo info,
- System.Runtime.Serialization.StreamingContext context): Base (info, context) {}
- }
"Go" How to quickly add code snippets in Visual Studio