Indexers

  • Thread starter Thread starter JMMB
  • Start date Start date
JMMB said:
Are there Indexers in VB.Net the same way they exist in C#?
thanks,

Maybe the "Default" keyword is what you're looking for:

default readonly property Item(ByVal Index as integer) As Object
get
return ...
end get
end property
 
JMMB,
To create an Indexer in VB.NET you define a 'Default' parameterized property

Public Class JMMBCollection

Default Public Readonly Property Item(index As Integer) as JMMB
Get
End Get
End Property

End Class

Which defines a readonly 'indexer'.

Note the property name does not need to be Item, the 'Default' keyword is
the key.

Hope this helps
Jay
 
JMMB said:
Are there Indexers in VB.Net the same way they exist in C#?

\\\
Public Class FooCollection
Private m_Foo() As Foo

Default Public ReadOnly Property Item(ByVal Index As Integer) As Foo
Get
Return m_Foo(Index)
End Get
End Property
End Class
///
 
Back
Top