嘿,我想下面的代碼從這個網頁ASP.NET錯誤與會話密鑰字符串
http://msdn.microsoft.com/en-us/magazine/cc163730.aspx
轉換爲VB.NET和有方法轉換爲這樣的
' 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(name As String)As Object':匹配參數'name'的參數從'Double'縮小到'String'。