I'm having trouble converting this FOR loop from VB.NET to C#:
Here's the VB.NET code:
Dim localCart As Object
localCart = Session("cart")
For i = 0 To UBound(localCart, 2)
If CStr(localCart(CARTID, i)) <> "" Then
orderTotal = orderTotal + (CDbl(localCart(CARTPPRICE, i)) *
CDbl(localCart(CARTPQUANTITY, i)))
'do something
End If
Next
I used a VB.NET to C# converter called Instrant C# and this is what I
got:
object localCart;
localCart = Session["cart"];
int tempFor1 = localCart.GetUpperBound(1);
for (i = 0; i <= tempFor1; i++)
{
if (System.Convert.ToString(localCart(CARTID, i)) != "")
{
orderTotal = orderTotal +
(System.Convert.ToDouble(localCart(CARTPPRICE, i)) *
System.Convert.ToDouble(localCart(CARTPQUANTITY, i)));
//do something
}
}
And here's the error message:
Compiler Error Message: CS0117: 'object' does not contain a
definition for 'GetUpperBound'
Any solutions please!
*** Sent via Developersdex http://www.developersdex.com ***