• Visual studio常用的code snippets


    作为全球第一的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


    作者:xiao.chun(小春)
    我的独立博客:http://1few.com
    本文版权归作者和博客园共有,欢迎转载,但未经作者同意必须保留此段声明,且在文章页面明显位置给出原文连接,否则保留追究法律责任的权利.

  • 相关阅读:
    ActionForm补充
    ActionForward
    struts模式匹配
    ActionMapping
    struts1.x的国际化
    DispatchAction
    ActionForm作为类型转换
    struts自定义异常
    hibernate核心接口
    Visual C# 2008+SQL Server 2005 数据库与网络开发 9.5 小结
  • 原文地址:https://www.cnblogs.com/asis/p/6349628.html
Copyright © 2020-2023  润新知