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
Can we maintain state in webservice?
How do you declare a variable in c#?
How do you achieve polymorphism in c#?
What is a private method in c#?
HOW to Develope the CRUD(create,read,update,delete) FORM IN WINDOWS form by using c# only
how to implement a web service in .net
code for arranging given number in possible permutation ways ex:123,321,312,132,231,213.
What is the difference between firstordefault and first?
Define assert() method? How does it work?
How do I do implement a trace and assert?
What is lazy in c#?
How do you determine whether a string represents a numeric value?
What is the advantage of constructor in c#?
How do you sort an array in c#?
What is system console writeline in c#?