حذف آیتم (ها) از ArrayList در #C
سلام بر تمامی برنامه نویسان سی شارپ 😉 در این مطلب ، حذف آیتم یا آیتمها از ArrayList در سی شارپ #C رو براتون آماده کردم. انشاالله که این کد براتون مفید باشه.
همچنین حذف object از ArrayList رو هم یاد می گیرید.
خروجی پروژه به این صورت می باشد:
Adding 6 elements
Removing 2 elements
Number of elements: 4
Removing 2 elements
Number of elements: 4
حذف آیتم (ها) از ArrayList :
using System;
using System.Collections;
class MainClass {
public static void Main() {
ArrayList al = new ArrayList();
Console.WriteLine("Adding 6 elements");
// Add elements to the array list
al.Add('C');
al.Add('A');
al.Add('E');
al.Add('B');
al.Add('D');
al.Add('F');
Console.WriteLine("Removing 2 elements");
// Remove elements from the array list.
using System.Collections;
class MainClass {
public static void Main() {
ArrayList al = new ArrayList();
Console.WriteLine("Adding 6 elements");
// Add elements to the array list
al.Add('C');
al.Add('A');
al.Add('E');
al.Add('B');
al.Add('D');
al.Add('F');
Console.WriteLine("Removing 2 elements");
// Remove elements from the array list.