A PHP Error was encountered

Severity: 8192

Message: str_replace(): Passing null to parameter #3 ($subject) of type array|string is deprecated

Filename: libraries/Filtered_db.php

Line Number: 23

C# program to remove the first occurrence of a specific object from the ArrayList (ArrayList.Remove() Method)
Q:

C# program to remove the first occurrence of a specific object from the ArrayList (ArrayList.Remove() Method)

0

C# program to remove the first occurrence of a specific object from the ArrayList (ArrayList.Remove() Method)

All Answers

need an explanation for this answer? contact us directly to get an explanation for this answer

Program:

The source code to remove the first occurrence of a specific object from 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("ABC");
            List.Add("XYZ");
            List.Add("PQR");
            
            List.Add(1.15);
            List.Add(2.25);
            List.Add(3.35);
            List.Add(4.45);
            List.Add(5.55);

            object[] objArray1 = List.ToArray();

            Console.WriteLine("Values in array list before Remove");
            foreach (object val in objArray1)
            {
                Console.WriteLine(val);
            }
            
            List.Remove("XYZ");

            object[] objArray2 = List.ToArray();

            Console.WriteLine("\n\nValues in array list after remove");
            foreach (object val in objArray2)
            {
                Console.WriteLine(val);
            }
        }
    }
}

Output:

Values in array list before Remove
ABC
XYZ
PQR
1.15
2.25
3.35
4.45
5.55


Values in array list after remove
ABC
PQR
1.15
2.25
3.35
4.45
5.55
Press any key to continue . . .

need an explanation for this answer? contact us directly to get an explanation for this answer

total answers (1)

Similar questions


need a help?


find thousands of online teachers now