user952982
user952982

Reputation: 11

C# code conversion

Can someone tell help me what is the VB.NET 2010 equivalent of the following code extract: What does the "this" gets converted to? I need a little help here please. Thanks guys.

public class CartItemList
{
  public CartItem this[int index]
  {
   get{ return cartItems[index];}
   set{ cartItems[index] = value;}
  } 
}

Upvotes: 0

Views: 45

Answers (2)

Henry
Henry

Reputation: 1008

Public Class CartItemList
    Default Public ReadOnly Property Item(id As String) As Cart
        Get 
            Return id + Now().ToString()
        End Get
    End Property
End Class

Upvotes: 0

Jon Skeet
Jon Skeet

Reputation: 1503479

It's a default property in VB, e.g.

Default Public Property Item(ByVal id As String) As Cart
    Get
        Return id & Now().ToString
    End Get
End Property

(It's not clear how the string is meant to be converted to a Cart even in the C# code, mind you...)

Upvotes: 5

Related Questions