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