Strictly speaking a C# indexer is not the same thing as a VB indexed property. In VB you can have as many indexed properties as you like, but only one of them can be declared Default. The Default property is the one whose name you can omit when using it, so it looks like you're indexing the class itself. For instance, The ArrayList.Item property is declared Default. You can access it like this:
vb.net Code:
myObject = myArrayList.Item(i)
or like this:
vb.net Code:
myObject = myArrayList(i)
in C# that's:
vb.net Code:
myObject = myArrayList.Item[i];
and:
vb.net Code:
myObject = myArrayList[i];
A C# indexer is equivalent to a VB Default Property. In VB Default properties MUST be indexed.
Now, as I said, in VB you can have as many indexed properties as you like, but only the one declared Default can be omitted in code. In C# you can have one indexer and that is the only indexed property you're allowed. Now, having said this, it is possible to overload properties so if the number or type of the index arguments vary then, strictly speaking, you can have multiple indexers in C#. It is considered bad practice to have overloaded indexers return different data though. Generally it will be the same data indexed by, say, ordinal index and string key.
Because VB indexed properties are named, you can have as many as you like with the same argument list, which is absolutely not possible in C#.
In summary, the code in post #1 actually has no direct translation in C#, while the code in post #2 actually translates directly to this:
Code:
Default Public Property Item(ByVal index As Integer) As Object
Get
'return the specified index here
End Get
Set(ByVal value As Object)
'set the specified index to value here
End Set
End Property
If your VB class only has one indexed property then it's not a problem, although you will not be able to name it Randomizer in C#. If your VB class has another indexed property declared default though, then you're stuffed. You'd have to declare Randomizer as discrete getter and setter methods rather than as a property.