Search:
Namespaces
Discussions
.NET v1.1
Feedback
index property accessor method
Messages
Related Types
This message was discovered on
ASPFriends.com 'aspngvb' list
.
Bryan Costanich
all,
does anyone know the equivalent vb.net syntax for the following c# index
property accessor method:
public foo this[int index]
{
get
{
return ((foo)this[index]);
}
set
{
foo[index] = value;
}
}
i tried:
'---- index accessor
public property me[index as integer] as Foo
Get
return (CType(me[index], Foo))
End Get
Set(ByVal Value)
Me[index] = Value
End Set
End Property
but i get "Keyword is not valid as an identifier" for me
Is there even anything that would be valid in vb.net like this?
(just for context, this is for a strongly-typed collection based on the
CollectionBase
class)
-b
Reply to this message...
Bryan Costanich
nevermind, figured it out. I forgot that vb.net doesn't use default
indexers like c#.... the correct code is as follows:
'---- index accessor
Public Overloads Property InnerList(ByVal index As Integer) As foo
Get
Return (CType(InnerList(index), foo))
End Get
Set(ByVal Value As foo)
InnerList(index) = Value
End Set
End Property
[Original message clipped]
Reply to this message...
Bryan Costanich
ok, the problem with this method is that i can't consume it via the follwing
object.Foos(index).property = blah
instead i have to do the following:
object.Foos.InnerList(index).property = blah
is there any way around this in vb.net or is it a limitation??
[Original message clipped]
Reply to this message...
Idrfsise Abfdsdi
If extending the
CollectionBase
class, use the DEFAULT keyword
--------------------------------
From: Idrfsise Abfdsdi
Reply to this message...
Idrfsise Abfdsdi
If extending the
CollectionBase
class, use the DEFAULT keyword
--------------------------------
From: Idrfsise Abfdsdi
Reply to this message...
System.Collections.CollectionBase
Ad
MBR BootFX
Best-of-breed application framework for .NET projects, developed by Matthew Baxter-Reynolds and MBR IT
Copyright © Matthew Baxter-Reynolds 2001-2008. '.NET 247 Software Development Services' is a trading style of MBR IT Solutions Ltd.
Contact Us
-
Terms of Use
-
Privacy Policy
-
www.dotnet247.com