We are providing online training of realtime Live project on Asp.Net MVC with Angular and Web API. For more information click here. If you have any query then drop the messase in CONTACT FORM

Saturday, June 27, 2015

Create an Array list as set of names, add single and range of values to the array list ,define your own methods to delete single value, range of values.

class Program
    {
        static void Main(string[] args)
        {
            ArrayList names = new ArrayList();
            names.Add("Mithilesh");
            names.Add("Dhanajee");
            names.Add("Rakesh");
            names.Add("DaveDas");
            names.Add("Amod");
            foreach (string name in names)
            {
                Console.WriteLine(name);
            }

            Console.WriteLine();
            Console.ReadLine();
            ArrayList objName = new ArrayList();
            objName.Add("Mohan");
            objName.Add("Sohan");
            objName.Add("Ram");
            objName.Add("Sonu");
            objName.AddRange(names);
            foreach (string name in objName)
            {

                Console.WriteLine(name);

            }
                      
            DeleteSingle(objName);

            objName.RemoveRange(3, 3);
            Console.WriteLine("After Deleting the Range");
            foreach (string name in objName)
            {
                Console.WriteLine(name);
            }
            Console.ReadLine();
        }
        public static void DeleteSingle(ArrayList list)
        {

            Console.WriteLine("Enter the Name which you want to delte");
            string str1 = Console.ReadLine();
            list.Remove(str1);
            Console.WriteLine();

            foreach (string name in list)
            {
                Console.WriteLine(name);

            }
            Console.ReadLine();
        }


    }

Output:


No comments: