帮忙把 戏VB.NET的代码转为C#,因为有些关键字,好像在C#中没有对应的。
故名思义,这是一个图书集合的类,从 《MSDN开发精选》上抄的,但是在C#里都不知道怎么实现。
无法转换的关键字有:NotInheritable, Shadows
Public NotInheritable Class BookCollection : Inherits ArrayList
Default Public Shadows Property Item(ByVal productid As Integer) As Book
Get
Return Me(IndexOf(productid))
End Get
Set(ByVal Value As Book)
Me(IndexOf(productid)) = Value
End Set
End Property
Public Overloads Function Contains(ByVal productId As Integer) As Boolean
Return (-1 <> IndexOf(productId))
End Function
Public Overloads Function IndexOf(ByVal productId As Integer) As Integer
Dim index As Integer = 0
Dim item As Book
For Each item In Me
If item.productID = productId Then
Return index
End If
index += 1
Next
Return -1
End Function
Public Overloads Sub RemoveAt(ByVal productId As Integer)
RemoveAt(IndexOf(productId))
End Sub
Public Shadows Function Add(ByVal value As Book) As Integer
Return MyBase.Add(value)
End Function
End Class