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 assembly versioning in .NET prevent DLL Hell problem?
What is c sharp used for?
Why is .net so popular?
What is difference between new and override in c#?
What is yield in c#?
Is it possible to have different access modifiers on the get/set methods of a property in c#?
Can constructor have return type c#?
How to do and Apply Themes to Datagrid,Lable,Textbox,etc., in C#.NET 2005 Windows Application? (like who we will do themes in ASP.NET using .CSS and .SKIN files). Urgent!!
How C# 4.0 supports dynamic programming language?
What is session state in asp net c# with example?
Can the nested class access, the containing class. Give an example?
Is collection a data structure?
What are the advantages of using delegates in c#?
If you define a user defined data type by using the class keyword, is it a value type or reference type?
Can a dictionary have the same key?