aijazasoomro
January 8th, 2009, 05:33 PM
Hi All,
I have tried to access the ArrayList Elements by following Code: ( This is Visual C++ .Net Code)
ArrayList^ myAL = gcnew ArrayList;
myAL->Insert( 0, "The" );
myAL->Insert( 1, "fox" );
myAL->Insert( 2, "jumps" );
myAL->Insert( 3, "over" );
myAL->Insert( 4, "the" );
myAL->Insert( 5, "dog" );
myAL->Insert(6,"cat");
.....
...
myAL->Insert(5000,"abc");
IEnumerator^ myEnum = myAL->GetEnumerator();
while ( myEnum->MoveNext() )
{
Object^ obj = safe_cast<Object^>(myEnum->Current);
Console::Write( " {0}", obj );
}
Is there any other way to Access Only a Single Element Without IEnumerator.
Because If I need only one element then What is the need to get the IEnumerator.
I am looking for searching a element based on particular index.
Any Help In this Regard will be Highly Appreciated.
Aijaz Soomro.
I have tried to access the ArrayList Elements by following Code: ( This is Visual C++ .Net Code)
ArrayList^ myAL = gcnew ArrayList;
myAL->Insert( 0, "The" );
myAL->Insert( 1, "fox" );
myAL->Insert( 2, "jumps" );
myAL->Insert( 3, "over" );
myAL->Insert( 4, "the" );
myAL->Insert( 5, "dog" );
myAL->Insert(6,"cat");
.....
...
myAL->Insert(5000,"abc");
IEnumerator^ myEnum = myAL->GetEnumerator();
while ( myEnum->MoveNext() )
{
Object^ obj = safe_cast<Object^>(myEnum->Current);
Console::Write( " {0}", obj );
}
Is there any other way to Access Only a Single Element Without IEnumerator.
Because If I need only one element then What is the need to get the IEnumerator.
I am looking for searching a element based on particular index.
Any Help In this Regard will be Highly Appreciated.
Aijaz Soomro.