Indexers in VB

bri189a

Senior Contributor
Joined
Sep 11, 2003
Messages
1,004
Location
VA
in C# I can:
public bool this[int index] {
get {
if (index < 0 || index >= length) {
throw new IndexOutOfRangeException();
}
return (bits[index >> 5] & 1 << index) != 0;
}
set {
if (index < 0 || index >= length) {
throw new IndexOutOfRangeException();
}
if (value) {
bits[index >> 5] |= 1 << index;
}
else {
bits[index >> 5] &= ~(1 << index);
}
}

Why can't I do this in VB? I've treid using Item, but that doesn't result in anything. Of coarse I tried Me and VB through a fit.

Thanks
 
An indexer would probably be like this, by using the Default keyword.

Visual Basic:
Public Default Property Item(ByVal Index As Integer)
  Get
    ...
  End Get
  Set
    ...
  End Set
End Property
 
Back
Top