在C#中:
private string studentName;
分号后的行尾(;)只需按
Ctrl + R + E
它将显示如下弹出窗口:
单击Apply或按ENTER键将生成以下属性代码:
public string StudentName
{
get
{
return studentName;
}
set
{
studentName = value;
}
}
在VB中:
Private _studentName As String
在行尾(在String之后)按, Make sure you place _(underscore) at the start because it will add number at the end of property:
Ctrl + R + E
同一个窗口会出现:
单击Apply或按ENTER键将生成以下带有数字的属性代码,如下所示:
Public Property StudentName As String
Get
Return _studentName
End Get
Set(value As String)
_studentName = value
End Set
End Property
数字属性是这样的:
Private studentName As String
Public Property StudentName1 As String
Get
Return studentName
End Get
Set(value As String)
studentName = value
End Set
End Property