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