Groups | Blog | Home
all groups > vb.net > january 2004 >

vb.net : Stuck... what the Syntax of doing...



eff_kay
1/28/2004 11:51:10 PM
Hi

Can somebody please tell me a simple thingy? How can I declare Indexers in VB .NET ???

MSDN comes up with C# topics indtead of VB thought I have filtered !! Its like ten thousan spoons when I need a knife!!

Thanks and have a nice and productive day!

Jan Tielens
1/29/2004 10:54:04 AM
Public Class MyCollection
....
Public Default Property Item(index As Integer) As String
....
End Property
End Class

Are you looking for this?

--
Greetz

Jan Tielens
________________________________
Read my weblog: http://weblogs.asp.net/jan


[quoted text, click to view]

hirf-spam-me-here NO[at]SPAM gmx.at
1/29/2004 7:14:53 PM
* "=?Utf-8?B?ZWZmX2theQ==?=" <anonymous@discussions.microsoft.com> scripsit:
[quoted text, click to view]

Something like that:

\\\
Public Default Property Item(ByVal Index As Integer) As Integer
Get
Return array(Index)
End Get
Set(ByVal Value As Integer)
array(Index) = Value
End Set
End Property
///

As you can see, in VB.NET indexers are treated as properties. That's
why you can access them by their name: 'Foo(1)' is the same as
'Foo.Item(10)'. The latter cannot be done in C#.

--
Herfried K. Wagner [MVP]
AddThis Social Bookmark Button