Visual studio经常使用的code snippets

做为全球第一的IDE,VS用起来天然至关的爽,当你在visual studio里敲出几个字母,能帮你生成一大段代码,省时省力又能装逼。
好比,你打一个 prop,而后按tab键,就能生成一个带get/set的属性出来。
用好vs的代码片断,是牛逼.Net程序员必备技能。程序员

prop

属性:函数

public int PropertyA { get; set; }

propg

只读属性this

public int PropertyB { get; private set; }

propfull

完整属性code

private int fieldC;

public int PropertyC
{
    get { return fieldC; }
    set { fieldC = value; }
}

ctor

默认构造函数(不带参数)orm

public MyClass()
{
    
}

ctorp

构造函数并自动识别类里面的属性ci

public MyClass(int propertyA, int propertyB)
{
    PropertyA = propertyA;
    PropertyB = propertyB;
}

ctorf

构造函数并自动识别类里面的fieldget

public MyClass(int fieldC)
{
    this.fieldC = fieldC;
}

ctorfp

构造函数并同时识别类里面的field和属性string

public MyClass(int fieldC, int propertyA, int propertyB)
{
    this.fieldC = fieldC;
    PropertyA = propertyA;
    PropertyB = propertyB;
}

~

析构函数it

~MyClass()
{

}

for

for (int i = 0; i < UPPER; i++)
{
}

forr

for (int i = length - 1; i >= 0; i--)
{
}

indexer

public object this[int index]
{
    get {  /* return the specified index here */ }
    set
    {
        /* set the specified index to value here */
    }
}

sim

static int main函数io

static int Main(string[] args)
{
    
    return 0;
}

svm

staic void main函数

static void Main(string[] args)
{
    
}

mbox

System.Windows.Forms.MessageBox.Show("Test");

cw

Console.WriteLine();

tryf

try-finally

try
{
    
}
finally
{
    
}

一些其余的代码片断不少人都用过了,不过也许有的人尚未意识到,原来这就是vs的代码片断。
除了系统自带的之外,还能够本身动手添加本身的代码片断,参见:MSDN

相关文章
相关标签/搜索