New Message on dotNET User Group Hyd

Accessing Indexer by using Indexer Name

Reply
  Reply to Sender   Recommend Message 2 in Discussion
From: Aghastya

Hi Saroja,

I think there is limitation in the C# language to access the indexer using its Name. Anyways it is accessible using class instance.

But the same is accessible in VB.NET. Here is the code

In C#.net

public class TestIndexer {

public TestIndexer() {

ar.Add ( " hi " );

ar.Add ( " how r u " );

}

ArrayList ar = new ArrayList();

[System.Runtime.CompilerServices.IndexerName("MyIndex")]

public string this [int index]

{

get { return ar[index].ToString() ; }

set { ar[index] = value; }

}

}

 

 

 

In Vb.net

Public class XY {

Public sub New()

{

Dim ti as new TestIndexer

Ti.MyIndex[0]="Hello"

}

}

 

Things work fine in the above code listed, i.e vb.net but there is a limitation in C#. for more information refer the msdn link ---

 

ms-help://MS.VSCC.2003/MS.MSDNQTR.2004OCT.1033/cpref/html/frlrfSystemRuntimeCompilerServicesIndexerNameAttributeClassTopic.htm

 

Cheers :)

Nagesh


View other groups in this category.

Click Here
Also on MSN:
Start Chatting | Listen to Music | House & Home | Try Online Dating | Daily Horoscopes

To stop getting this e-mail, or change how often it arrives, go to your E-mail Settings.

Need help? If you've forgotten your password, please go to Passport Member Services.
For other questions or feedback, go to our Contact Us page.

If you do not want to receive future e-mail from this MSN group, or if you received this message by mistake, please click the "Remove" link below. On the pre-addressed e-mail message that opens, simply click "Send". Your e-mail address will be deleted from this group's mailing list.
Remove my e-mail address from dotNET User Group Hyd.

Reply via email to