帮忙把 戏VB.NET的代码转为C#,因为有些关键字,好像在C#中没有对应的。

JB-Zhang 2005-01-09 01:21:36
故名思义,这是一个图书集合的类,从 《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
...全文
118 8 打赏 收藏 转发到动态 举报
写回复
用AI写文章
8 条回复
切换为时间正序
请发表友善的回复…
发表回复
linfengcyl 2005-01-14
  • 打赏
  • 举报
回复
this 吧
caofengnan 2005-01-13
  • 打赏
  • 举报
回复
hehe
smallMage 2005-01-13
  • 打赏
  • 举报
回复
学习
JB-Zhang 2005-01-13
  • 打赏
  • 举报
回复
怎么没人来?
liulxmooo 2005-01-11
  • 打赏
  • 举报
回复
up
JB-Zhang 2005-01-10
  • 打赏
  • 举报
回复
第一个shadows 方法的 Default 关键字呢?
hujiiori 2005-01-09
  • 打赏
  • 举报
回复
Shadows-->new
yufenfeila 2005-01-09
  • 打赏
  • 举报
回复
NotInheritable 对应 sealed

17,740

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术 .NET Framework
社区管理员
  • .NET Framework社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧