The source code to add an object to the end of the ArrayList is given below. The given program is compiled and executed successfully.
using System;
using System.Collections;
namespace mynamespace
{
class Program
{
//Entry point of program
static void Main(string[] args)
{
ArrayList List = new ArrayList();
List.Add(10);
List.Add(20);
List.Add(30);
List.Add(40);
List.Add(50);
List.Add("India");
List.Add("Srilanka");
List.Add("Nepal");
List.Add("Bhutan");
object[] objArray = List.ToArray();
Console.WriteLine("Values in array list");
foreach (object val in objArray)
{
Console.WriteLine(val);
}
}
}
}
Output:
Values in array list
10
20
30
40
50
India
Srilanka
Nepal
Bhutan
Press any key to continue . . .
Program:
The source code to add an object to the end of the ArrayList is given below. The given program is compiled and executed successfully.
Output:
need an explanation for this answer? contact us directly to get an explanation for this answer