Today found a very useful shortcut built, ctrl+r,ctrl+e These two key combinations, you can automatically generate the properties of the Get
and set methods .
And the Java syntax is different, in addition to the Get/set method of writing, there are.
net in both field and properity.
field is a private field, used internally, to have a bottom line before the variable name. Properity is a public property that is externally visible, with no line drawn before the variable name.
Of course, you can also use the mouse to select a field variable without a shortcut key, and then right-click Refactor (refactor) and Encapuslatefield (encapsulate the field). The effect is as follows:
#region field
private int _levelid;
private string _levelname;
#endregion
#region properity public
int levelid
{get
{return _levelid;}
set {_levelid = value;}
}
public string LevelName
{get
{return _levelname;}
set {_levelname = value;}
}
#endregion
The better thing is to just type in the prop and then press TAB twice. The Get and set are automatically generated. You only need to modify the property name.