新手请教,由C#的类代码转为VB代码的问题.
C#中的代码为:
private int recordCount; //声明属性
private int pageCount; //声明属性
.......
public int RecordCount
{
get{return recordCount;}
set{recordCount = value;}
}
public int PageCount
{
get{return this.DataGrid1.PageCount;}
set{PageCount = value;}
}
现转为VB代码后:
Private recordCount As Integer
Private pageCount As Integer
........
Public Property RecordCount() As Integer
Get
Return recordCount
End Get
Set
recordCount = value
End Set
End Property
Public Property PageCount() As Integer
Get
Return Me.DataGrid1.PageCount
End Get
Set
PageCount = value
End Set
End Property
现出现如下错误:
编译器错误信息: BC30260: “pageCount”已声明为此 class 中的“Private Dim pageCount As Integer”。
源错误:
行 134: End Sub
行 135:
行 136: Public Property PageCount() As Integer
行 137: Get
行 138: Return Me.DataGrid1.PageCount
请问该如何解决呢?
[解决办法]
Public Property PageCount() As Integer
Get
Return Me.DataGrid1.pageCount
End Get
Set
pageCount = value
End Set
End Property
[解决办法]
VB中不区分大小写(当然可以设置)
Private Dim pageCount As Integer -> Private Dim _pageCount As Integer