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
How to handle exceptions that are raised in a component?
In a site to turn off cookies for one page which method is followed?
Can you pass parameters to destructors?
Can we override interface methods in c#?
4. Describe the process when we send a request URL? And who is responsible for that?
Is array passed by reference in c#?
What are circular references? How garbage collection deals with circular references.
Explain different properties of object oriented systems.
Can we change static value in c#?
Is ram a heap?
What is array and its types in c#?
What is helper method in c#?
What are namespaces, and how they are used?
List some of the common data providers for ado.net framework?
What is difference between var dynamic and object in c#?