Use C # development tools to automatically create some basic code

Source: Internet
Author: User

 

Self-taught C # Sometimes there are many good functions in IDE because there are few people communicating with each other, learning is indeed a little difficult, but these tips are indeed to reduce the amount of code coding, but it is still very standard.

I want to find some information on the Internet, but I have not found it. It is estimated that most people can easily learn and communicate with each other through systematic learning.

Maybe I just summarized a small part and hope to learn more about it. Thank you first ........

1. encapsulate attributes and fields

1. Declare a local variable

Private int _ id; // '* No.

2. Select the variable name, right-click the variable name, and choose "refactor"> "encapsulate field ".

Public int ID
{
Get {return _ id ;}
Set {_ id = value ;}
}

2. Implementation Interface

1. Select the name of the interface to be implemented by the class, right click-implement interface-implement display interface

Class dbcustomer: dbbase, dbbase. itableoperate
{

# Region itableoperate Member

Void dbbase. itableoperate. addnew ()
{
Throw new exception ("the method or operation is not implemented .");
}

Void dbbase. itableoperate. Update (long ID)
{
Throw new exception ("the method or operation is not implemented .");
}

# Endregion

}

3. Notes

1. Fields

After "//" is entered on the last line of the declared field, the following code is automatically generated.

Private int _ id;

/// <Summary>
///

/// </Summary>
Public int ID
{
Get {return _ id ;}
Set {_ id = value ;}
}

Insert the comments of this field in the middle

Private int _ id;

/// <Summary>
/// No.
/// </Summary>
Public int ID
{
Get {return _ id ;}
Set {_ id = value ;}
}

2. Method

After "//" is entered in the previous line of the declared method, the following code is automatically generated.

/// <Summary>
///
/// </Summary>
/// <Param name = "strsql"> </param>
/// <Param name = "LV"> </param>
/// <Param name = "imageid"> </param>
Public void querytolv (string strsql, ref listview LV, int imageid)

In fact, writing comments may include (parameters and returned values are automatically generated by the method body)

/// <Summary>
/// Import the query result to listview
/// </Summary>
/// <Param name = "strsql"> query statement </param>
/// <Param name = "LV"> listview Control </param>
/// <Param name = "imageid"> the small icon ID used by listview item </param>
Public void querytolv (string strsql, ref listview LV, int imageid)

Author: Duan Liqing

2010-03-25

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.