首页 技术 正文
技术 2022年11月17日
0 收藏 622 点赞 2,163 浏览 1106 个字

作为全球第一的IDE,VS用起来自然相当的爽,当你在visual studio里敲出几个字母,能帮你生成一大段代码,省时省力又能装逼。

比如,你打一个 prop,然后按tab键,就能生成一个带get/set的属性出来。

用好vs的代码片段,是牛逼.Net程序员必备技能。

prop

属性:

public int PropertyA { get; set; }

propg

只读属性

public int PropertyB { get; private set; }

propfull

完整属性

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

ctor

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

public MyClass()
{}

ctorp

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

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

ctorf

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

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

ctorfp

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

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

~

析构函数

~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函数

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

上一篇: cpp(第十一章)
下一篇: [BZOJ1597]土地购买
相关推荐
python开发_常用的python模块及安装方法
adodb:我们领导推荐的数据库连接组件bsddb3:BerkeleyDB的连接组件Cheetah-1.0:我比较喜欢这个版本的cheeta…
日期:2022-11-24 点赞:878 阅读:8,990
Educational Codeforces Round 11 C. Hard Process 二分
C. Hard Process题目连接:http://www.codeforces.com/contest/660/problem/CDes…
日期:2022-11-24 点赞:807 阅读:5,504
下载Ubuntn 17.04 内核源代码
zengkefu@server1:/usr/src$ uname -aLinux server1 4.10.0-19-generic #21…
日期:2022-11-24 点赞:569 阅读:6,348
可用Active Desktop Calendar V7.86 注册码序列号
可用Active Desktop Calendar V7.86 注册码序列号Name: www.greendown.cn Code: &nb…
日期:2022-11-24 点赞:733 阅读:6,133
Android调用系统相机、自定义相机、处理大图片
Android调用系统相机和自定义相机实例本博文主要是介绍了android上使用相机进行拍照并显示的两种方式,并且由于涉及到要把拍到的照片显…
日期:2022-11-24 点赞:512 阅读:7,765
Struts的使用
一、Struts2的获取  Struts的官方网站为:http://struts.apache.org/  下载完Struts2的jar包,…
日期:2022-11-24 点赞:671 阅读:4,843