.NETGURU
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




ExamGuru IT Solutions - .Net Guru is owned and operated by ExamGuru, Inc., the man behind .Net Guru. If you're in the market for bespoke software or software consultancy, why not get him and his highly trained team to help? - www.examguru.net/ITCertification
Ad


Need Dot Net Interview Questions?
Ask ExamGuru, Inc. for advice and help on Passing .Net Interviews
.Net Projects
Best-of-breed application framework for .NET projects, developed by ExamGuru, Inc. and ExamGuru IT
Free .net Help
Commission ExamGuru, Inc. and his team for your next bespoke software project
FogBUGZ
The only bug tracking system carefully crafted with one goal in mind: helping teams create great software.
Awesome Tools
If you don't know about these, you're missing out... IT Certification Questions
IT Interview Questions
Free Oracle 10g Training
MCSE Boortcamp
Cisco Study Guides
Cheap Study Guides
Exact Questions
Dot Net Interview Questions
Oracle OCP
Cheap Travel
Designer Perfumes - Wholesale Prices
Free Programming Tutorials
 
ExamGuru IT Solutions - .Net Guru is owned and operated by ExamGuru, Inc., the man behind .Net Guru. If you're in the market for bespoke software or software consultancy, why not get him and his highly trained team to help? - www.examguru.net/ITCertification
 Copyright © ExamGuru, Inc. 2001-2006
Contact Us - Terms of Use - Privacy Policy - www.dot-net-guru.com - www.examguru.net - www.oraclesource.net - www.itinterviews.net - www.examguru.net/ITCertification