Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 511951
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T07:16:11+00:00 2026-05-13T07:16:11+00:00

Classes in .net like List and Dictionary can be indexed directly, without mentioning a

  • 0

Classes in .net like List and Dictionary can be indexed directly, without mentioning a member, like this:

Dim MyList as New List (of integer)
...
MyList(5) 'get the sixth element
MyList.Items(5) 'same thing

How do I make a class that can be indexed like that?

Dim c as New MyClass
...
c(5) 'get the sixth whatever from c
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-13T07:16:12+00:00Added an answer on May 13, 2026 at 7:16 am

    You need to provide an indexer (C# terminology) or default property (VB terminology). Example from the MSDN docs:

    VB: (myStrings is a string array)

    Default Property myProperty(ByVal index As Integer) As String
        Get
            ' The Get property procedure is called when the value
            ' of the property is retrieved.
            Return myStrings(index)
        End Get
        Set(ByVal Value As String)
            ' The Set property procedure is called when the value
            ' of the property is modified.
            ' The value to be assigned is passed in the argument 
            ' to Set.
            myStrings(index) = Value
        End Set
    End Property    
    

    And C# syntax:

    public string this[int index]
    {
        get { return myStrings[index]; }
        set { myStrings[index] = vaue; }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

A lot of the collection classes in .Net (i.e., List<T>, Dictionary<TKey, TValue>) have an
Are there any dictionary classes in the .NET base class library which allow duplicate
Edit: This was accidentally posted twice. Original: VB.NET Importing Classes I've seen some code
Is there a utility out there that will create VB.NET classes from a Dataset.xsd
Imagine I use the .NET graphic classes to draw a rectangle. How could I
What is best practice when creating your exception classes in a .NET solution: To
I'm just learning to work with partial classes in VB.NET and VS2008. Specifically, I'm
I am looking for satisfactory options for unit testing my .NET DAL classes; since
Somewhat unclear to me are references (pointers?) to classes in VB.NET. The question I
I have a .NET assembly that contains classes to be registered as ServicedComponent through

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.