【发布时间】:2011-08-03 09:49:01
【问题描述】:
嘿,我正在尝试将此网页中的以下代码转换为 VB.NET
http://msdn.microsoft.com/en-us/magazine/cc163730.aspx
并且有一个这样转换的方法
' Get the order from the session on demand
Private Shared Function GetOrderFromSession(ByVal i As Integer) As ShoppingCartOrder
Dim session As HttpSessionState = HttpContext.Current.Session
Dim ID As Integer = 0
Dim quantity As Integer = 0
' note: For simplicity session key strings are dynamically
' created——for performance reasons they should be precreated.
ID = CInt(session(ShoppingCartItemIDKeyBase + i))
quantity = CInt(session(ShoppingCartOrderQuantityKeyBase + i))
Dim item As ShoppingCartItem = ShoppingCartItem.GetItem(ID)
Return New ShoppingCartOrder(item, quantity)
End Function
但是在线条周围出现错误
ID = CInt(session(ShoppingCartItemIDKeyBase + i))
quantity = CInt(session(ShoppingCartOrderQuantityKeyBase + i))
错误 1 重载解析失败,因为没有缩小转换就无法调用可访问的“项目”: 'Public Default Property Item(index As Integer) As Object':参数匹配参数'index'从'Double'缩小到'Integer'。 “公共默认属性项(名称作为字符串)作为对象”:参数匹配参数“名称”从“双”缩小到“字符串”。
【问题讨论】:
标签: asp.net