473,396 Members | 1,789 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Access collection elements with the Dot (.) operator

Hello,

I remember reading in one of my books that it was possible to access some
collection's elements with the dot (.) operator just like if they were
properties. The problem is I don't remember what this kind of operation was
called thus making it difficult to find documentation about it.

I would apreciate if someone could just tell me the name of this operation
(of implementing collections with the dot operator) or the name of the
interface I must implement - anything that can help me find where I read
about it in the first place.

Thanks in advance,

Ana L.
Nov 16 '05 #1
1 1971
Hello Ana,

You might have read that it is possible to access elements of a collection
WITHOUT the dot operator.
In other words, instead of writing something like

myCollection.GetItemAt(myItemIndex)

it is possible to write

myCollection[myItemIndex].

To achieve this, you should implement a so called indexer. It looks like a
property, but is named "this". For example:

public object this[int index]
{
get
{
return _storage[index];
}
}

"Ana Lindt" <an*******@tukal.com> wrote in message
news:40********@epflnews.epfl.ch...
Hello,

I remember reading in one of my books that it was possible to access some
collection's elements with the dot (.) operator just like if they were
properties. The problem is I don't remember what this kind of operation was called thus making it difficult to find documentation about it.

I would apreciate if someone could just tell me the name of this operation
(of implementing collections with the dot operator) or the name of the
interface I must implement - anything that can help me find where I read
about it in the first place.

Thanks in advance,

Ana L.


Nov 16 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

8
by: Generic Usenet Account | last post by:
To settle the dispute regarding what happens when an "erase" method is invoked on an STL container (i.e. whether the element is merely removed from the container or whether it also gets deleted in...
10
by: Tom | last post by:
Hi I am looking for an optimal data-structure in order to replace a map<int,float>. I use it as some kind of sparse array representation. The facts: - the population in the data-structures...
8
by: William Bradley | last post by:
First of all I have been working with Access 97 and this morning the owner of the business phoned me to inform me that he had updated to Access 2000 and parts of my forms would not work anymore. ...
6
by: Peter Frost | last post by:
Please help I don't know if this is possible but what I would really like to do is to use On Error Goto to capture the code that is being executed when an error occurs. Any help would be much...
10
by: aa7im | last post by:
I have a similiar thread going about this topic but I decided to break it off into a seperate discussion. Question: What is the best way to determine if an object "IsNew" to a collection? ...
11
by: Rob | last post by:
I know, I know, don't use frames. Well, I'm stuck with these frames and I'm trying to add functionality without a complete redsign. You can look at this as a nostalgic journey. Anyway, I've got...
3
by: jacob navia | last post by:
Abstract: Continuing the discussion about abstract data types, in this discussion group, a string collection data type is presented, patterned after the collection in C# and similar languages...
0
by: jbonifacejr | last post by:
Hello everyone. Very sorry if I am posting in the wrong place. I am writing a test harnes that will be required to interact with elements on a web page, such as inserting text in a text box. At...
36
by: Peter Olcott | last post by:
So far the only way that I found to do this was by making a single global instance of the container class and providing access to the contained class, through this single global instance. Are...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.