Answer Posted / sharmin jose
Everything told above is correct except that ArrayList can
only contain "similar data type".
Please compile and execute the following code:
using System;
using System.Collections;
public class SamplesArrayList {
public static void Main() {
// Creates and initializes a new ArrayList.
ArrayList MyList = new ArrayList();
MyList.Add("Hello");
MyList.Add("World");
MyList.Add(1);
// Displays the properties and values of the
ArrayList.
Console.WriteLine( "MyList" );
Console.WriteLine( "\tCount: {0}", MyList.Count );
Console.WriteLine( "\tCapacity: {0}",
MyList.Capacity );
Console.Write( "\tValues:" );
PrintValues( MyList );
}
public static void PrintValues( IEnumerable myAL ) {
System.Collections.IEnumerator myEnumerator =
myAL.GetEnumerator();
while ( myEnumerator.MoveNext() )
Console.Write( "\t{0}", myEnumerator.Current );
Console.WriteLine();
}
}
Is This Answer Correct ? | 1 Yes | 0 No |
Post New Answer View All Answers
What are the different ways of method can be overloaded?
How to find the current application file path while runtime?
How long does a loop recorder procedure take?
What are verbatim strings in c#?
What are Regex / regular expressions ?
What is an indexer in c#?
How to Show Message box in Metro Style App?
What is default class in c#?
What is difference between private and protected?
What is the task perform by clr?
What is polymorphism c# example?
What is the difference between a field and a property in c#?
Why to use “finally” block in c#?
What is the difference between static and private constructor in c#?
What is dapper in c#?