Posted by : Anwar Hossain
Category : asp.net c # basic tutorial

C Sharp ArrayList Property and Method

Dear viewers I will show some common Arraylist Property and Methods In C#. Common Arraylist Property are Capacity, Count, IsFixedSize, IsReadOnly, Item etc. Common Arraylist Methods are Add, AddRange, Clear, Contains, GetRange, Sort, Remove, RemoveAt,etc. I wil give some practical Arraylist example using console application.

C Sharp ArrayList Property and Method


Properties of the ArrayList class


C_Sharp_ArrayList_Property

Method of the ArrayList class


C_Sharp_ArrayList_Method

C # ArrayList Property and Method


using System;

using System.Collections.Generic;

using System.Linq;

using System.Text;

using System.Collections;

 

namespace Csharp_ArrayList

{

    class Program

    {

        static void Main(string[] args)

        {

            ArrayList CountryList = new ArrayList();

 

            CountryList.Add("Bangladesh");

            CountryList.Add("India");

            CountryList.Add("Pakistan");

            CountryList.Add("Nepal");

            CountryList.Add("Butan");

            CountryList.Add("Srilanka");

            CountryList.Add("Maldives");

            Console.WriteLine("\n\n=====================\n");

 

            foreach (object i in CountryList)

            {

              

                Console.WriteLine("\n {0}",i);

            }

            Console.WriteLine("\n\n==Array List Property");

 

            Console.WriteLine("\n Capacity: {0} ", CountryList.Capacity);

            Console.WriteLine("\n Count: {0}", CountryList.Count);

            Console.WriteLine("\n is Fixed Size: {0} ", CountryList.IsFixedSize);

            Console.WriteLine("\n Readonly: {0}", CountryList.IsReadOnly);

            Console.WriteLine("\n IsSynchronized: {0} ", CountryList.IsSynchronized);

 

 

            Console.WriteLine("\n\n==Array  List Method==");

 

            Console.WriteLine("\n\n==Array List Remove Method==");

 

            ArrayList CityList = new ArrayList();

            CityList.Add("Dhaka");

            CityList.Add("Chittagong");

            CityList.Add("Barisal");

            CityList.Remove("Chittagong");

 

            foreach (object i in CityList)

            {

 

                Console.WriteLine("\n {0}", i);

            }

 

 

            ArrayList StudentList = new ArrayList();

            StudentList.Add("Monir");

            StudentList.Add("Iqbal");

            StudentList.Add("Zabed");

            StudentList.Add("Anisur Rahman");

            StudentList.RemoveAt(1);

 

            Console.WriteLine("\n\n==Array List Sort and Remove Method==");

            StudentList.Sort();

 

            foreach (object i in StudentList)

            {

 

                Console.WriteLine("\n {0}", i);

            }

 

            Console.ReadKey();

 

        }

    }

}

 


Output


C_Sharp_ArrayList_Output



Realted Article Headline

How to find odd number in c #
How to generate random number in c #
Nested For Loop Example in C Sharp
Store C sharp reference type in a List C#
Find number of items in a List C#
Concept about C # List
Custom Time formatting example C #
Custom Date formatting example C #
String Format Example using ASP.Net C#
Simple enum example in C Sharp
Nested switch-case statement example in C #
Combined switch...case statement example in C #
C Sharp switch case statement Example
C# SUM ArrayList Element Example
C# String Class Methods Example
C Sharp String Class Properties and Methods
C Sharp String Class Example
How to join two ArrayList collections in C#.
How to Use C Sharp Math Class
C Sharp ArrayList Property and Method
C Sharp ArrayList Example
C Sharp Arrays Example
C Sharp Logical operator Example
C Sharp Relational operators
C Sharp Arithmetic operators Example
C Sharp Common Assignment Operator
Simple for loop example in c sharp

Article Category

How to create asp.net control dynamically
Learn HTML for beginner
DataList example in C Sharp
Mail sending in asp.net c#
State Management in ASP C #
Basic sql tutorial for Beginner
DataTable example in ASP.Net C#
How to use LINQ in ASP.NET C#
asp.net c # basic tutorial
How to use ajax toolkit in asp.net C#
How to use different types of validation control using asp.net c#
How to use grid view in asp.net c#
Protected by Copyscape Online Plagiarism Detection