Data Structure in C#

ArrayList Implementation Example:

using System;
using System.Collections;

namespace ArrayListIntroApp
{
    class Program
    {
        static void Main(string[] args)
        {
            ArrayList ourArrayList = new ArrayList();
            ourArrayList.Add("Hello World");
            ourArrayList.Add(12);
            ourArrayList.Add(true);
            ourArrayList.Add(124.2);
            ourArrayList.Add('A');

            foreach (var i in ourArrayList)
            {
                Console.WriteLine(i);
            }

            Console.ReadKey();
        }
    }
}

ArrayList example:

using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ListIntroApp
{
    class Program
    {
        static void Main(string[] args)
        {
            List<string> ourList=new List<string>();

            ourList.Add("Hello");
            ourList.Add("World");
            ourList.Add("BDjobs");
            ourList.Add("BAtch 06");
            ourList.Add("BDBL Bhaban");
            ourList.Add("Level 19");
            ourList.Add("Kawran Bazar");
            //ourList.Sort();
            //ourList.Reverse();
            ourList.RemoveRange(1,3);
          //  ourList.Remove("Hello");
          //  Console.WriteLine(ourList.Remove("Hello"));
            
            foreach (string item in ourList)
            {
                Console.WriteLine(item);
            }
            Console.ReadKey();
        }
    }
}

Stack:

using System;
using System.Collections.Generic;

namespace stack
{
    class Program
    {
        static void Main(string[] args)
        {
            Stack<int> ourStack=new Stack<int>();
            ourStack.Push(23);
            ourStack.Push(123);
            ourStack.Push(1);
            ourStack.Push(777);
            ourStack.Push(76);
            int[] ourArray = ourStack.ToArray();
            //Console.WriteLine(ourStack.Pop());
            //Console.WriteLine(ourStack.Pop());
            //Console.WriteLine(ourStack.Pop());
            //Console.WriteLine("Top Value: "+ourStack.Peek());
            Console.WriteLine(ourStack.Count);
            Console.WriteLine("Values in Array:");
            foreach (int item in ourArray)
            {
                Console.WriteLine(item);
            }
            Console.ReadKey();
        }
    }
}

 

Queue:

HashMap

Dicitionary:

 

It would be a great help, if you support by sharing :)
Author: zakilive

Leave a Reply

Your email address will not be published. Required fields are marked *