当前位置: 首页>>代码示例>>C#>>正文


C# GenericList.RemoveAtIndex方法代码示例

本文整理汇总了C#中GenericList.RemoveAtIndex方法的典型用法代码示例。如果您正苦于以下问题:C# GenericList.RemoveAtIndex方法的具体用法?C# GenericList.RemoveAtIndex怎么用?C# GenericList.RemoveAtIndex使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在GenericList的用法示例。


在下文中一共展示了GenericList.RemoveAtIndex方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Main

    static void Main()
    {
        GenericList<int> testList = new GenericList<int>();
        int chislo = 231;
        testList.Add(chislo);
        testList.Add(chislo);
        testList.InsertAtPosition(1, 5);
        testList.InsertAtPosition(1, 5);
        testList.Add(chislo + 9);

        int element = testList[0];
        Console.WriteLine(element);

        testList.RemoveAtIndex(3);

        testList.InsertAtPosition(0, 124);

        //testList.Clear();

        testList.FindElementByValue(421);

        testList.ToStringNew();

        int min = testList.Min();
        Console.WriteLine(min);

        int max = testList.Max();
        Console.WriteLine(max);
    }
开发者ID:hristo11111,项目名称:TelerikAcademy-HristoBratanov,代码行数:29,代码来源:Program.cs

示例2: Main

 static void Main()
 {
     GenericList<int> list1 = new GenericList<int>();
     List<int> alabala=new List<int>();
     alabala.Add(1);
     list1.Add(4);
     list1.Add(5);
     list1.Add(6);
     list1.Add(1);
     list1.Add(3);
     list1.Add(2);
     Console.WriteLine("-====Printing Generic List====-");
     Console.WriteLine(list1);
     Console.WriteLine("-====End Of Printing====-");
     Console.WriteLine();
     Console.WriteLine("Min="+list1.Min());
     Console.WriteLine("Max=" + list1.Max());
     Console.WriteLine("Element in index 5 is",list1[5]);
     Console.WriteLine("Removing element on at index 2");
     list1.RemoveAtIndex(2);
     Console.WriteLine("-====Printing Generic List====-");
     Console.WriteLine(list1);
     Console.WriteLine("-====End Of Printing====-");
     Console.WriteLine();
     Console.WriteLine("Inserting element 10 on at index 5");
     list1.InsertAt(5,2);
     Console.WriteLine("-====Printing Generic List====-");
     Console.WriteLine(list1);
     Console.WriteLine("-====End Of Printing====-");
     Console.WriteLine();
     Console.WriteLine("The index of element {0} is index {1}",6,list1.IndexOf(6));
     Console.WriteLine("The List contains element 5 : {0}",list1.Contains(5));
     Console.WriteLine("The List contains element 5 : {0}", list1.Contains(50));
     Console.WriteLine("Min element of the list is {0}",list1.Min());
     Console.WriteLine("Max element of the list is {0}", list1.Max());
     Console.WriteLine("The max size of the list is {0}",list1.ActuallCapacity);
     list1.Add(4);
     list1.Add(5);
     list1.Add(6);
     list1.Add(1);
     list1.Add(3);
     list1.Add(2);
     list1.Add(5);
     list1.Add(6);
     list1.Add(1);
     list1.Add(3);
     list1.Add(2);
     Console.WriteLine("-====Printing Generic List====-");
     Console.WriteLine(list1);
     Console.WriteLine("-====End Of Printing====-");
     Console.WriteLine("The max size of the list is {0}", list1.ActuallCapacity);
 }
开发者ID:AlexanderKrustev,项目名称:SoftUni,代码行数:52,代码来源:ListExample.cs

示例3: Main

        static void Main()
        {
            GenericList<int> list = new GenericList<int>(10);
            for (int i = 0; i < 6; i++)
            {
                list.Add(i);
            }
            Console.WriteLine(list.ToString());
            Console.WriteLine("List state after initialization: ");
            for (int i = 0; i < list.COUNT; i++)
            {
                Console.Write("{0} ", list.GetAtIndex(i));
            }

            list.RemoveAtIndex(2);
            Console.WriteLine("\nList state after removing element at index {0}: ", list.INDEX);
            for (int i = 0; i < list.COUNT; i++)
            {
                Console.Write("{0} ", list.GetAtIndex(i));
            }

            list.InsertAtIndex(7, 13);
            Console.WriteLine("\nList state after inserting element at index {0}: ", list.INDEX);
            for (int i = 0; i < list.COUNT; i++)
            {
                Console.Write("{0} ", list.GetAtIndex(i));
            }

            list.Add(14);
            Console.WriteLine("\nList state after adding an element: ");
            for (int i = 0; i < list.COUNT; i++)
            {
                Console.Write("{0} ", list.GetAtIndex(i));
            }

            list.Add(99);
            Console.WriteLine("\nList state after adding another element: ");
            for (int i = 0; i < list.COUNT; i++)
            {
                Console.Write("{0} ", list.GetAtIndex(i));
            }

            Console.WriteLine("\n" + list.ToString());

            Console.WriteLine("MAX: {0}", GenericList<int>.Max(list));
            Console.WriteLine("MIN: {0}", GenericList<int>.Min(list));

            Console.WriteLine(list.GetAtIndex(list.GetByValue(4)));
        }
开发者ID:iliantova,项目名称:Telerik-Homework,代码行数:49,代码来源:MinAndMax.cs

示例4: Main

        static void Main()
        {
            var list = new GenericList<int>();

            list.Add(10);
            list.Add(20);
            list.Add(30);

            Console.WriteLine(list); //[10, 20, 30]
            Console.WriteLine("Max: {0}", list.Max()); //30
            Console.WriteLine("Min: {0}", list.Min()); //10

            Console.WriteLine(list[0]); //10
            Console.WriteLine(list[1]); //20

            //Exception:
            //Console.WriteLine(list[-1]);
            //Console.WriteLine(list[3]);

            list[1] = 150;
            Console.WriteLine(list);

            Console.WriteLine(list.Contains(150)); //true
            Console.WriteLine(list.Contains(1000)); //false

            Console.WriteLine(list.IndexOf(30)); //2
            Console.WriteLine(list.IndexOf(1000)); //-1

            list.InsertAtIndex(0, 1000);
            Console.WriteLine(list.ToString()); //[1000, 10, 150, 30]

            list.RemoveAtIndex(0);
            Console.WriteLine(list); //[10, 150, 30]

            //Exception:
            //list.RemoveAtIndex(-1);
            //list.RemoveAtIndex(3);
            //list.InsertAtIndex(-1, 40);
            //list.InsertAtIndex(3, 33);

            Console.WriteLine(list.Pop()); //30
            Console.WriteLine(list); //[10, 150]

            list.Push(-60);
            Console.WriteLine(list); //[10, 150, -60]

            list.Clear();
            Console.WriteLine(list); //[]
        }
开发者ID:nickgenov,项目名称:ObjectOrientedProgramming,代码行数:49,代码来源:GenericListMain.cs

示例5: Main

        static void Main(string[] args)
        {
            GenericList<string> myStrList = new GenericList<string>();

            myStrList.Add("ivan");
            myStrList.Add("asen");
            myStrList.Add("gosho");
            myStrList.Add("pesho");

            myStrList.InsertAtIndex("bobi", 0);
            myStrList.RemoveAtIndex(1);

            Console.WriteLine(myStrList);

            myStrList.GetVersion();
        }
开发者ID:bulgariamitko,项目名称:SoftUniHomeWordsAndMore,代码行数:16,代码来源:Program.cs

示例6: Main

    static void Main(string[] args)
    {
        try
        {
            //Creating new list
            GenericList<int> intList = new GenericList<int>(20);

            //Overfill his capacity to make him auto grow
            int maxCapacity = intList.Capacity;
            for (int i = 1; i < maxCapacity * 2; i++)
            {
                intList.Add(i);
            }

            //Access elemtn by index
            Console.WriteLine(intList[9]);

            //Remove from index
            intList.RemoveAtIndex(9);

            //Insert new element at this position
            intList.InsertAtPosition(9, 100);

            //Look by value if the element is at this position
            Console.WriteLine(intList.FindByValue(100));

            //Find Min and Max value
            Console.WriteLine(intList.Min());
            Console.WriteLine(intList.Max());

            //Use overriden method ToString()
            Console.WriteLine(intList.ToString());

            //Clear list
            intList.Clear();

            //And print again whith ToString()
            Console.WriteLine(intList.ToString());

        }
        catch (Exception e)
        {

            Console.WriteLine("Error!" + e.Message);
        }
    }
开发者ID:Jarolim,项目名称:TelerikAcademy-1,代码行数:46,代码来源:Program.cs

示例7: Main

        static void Main()
        {
            GenericList<int> test = new GenericList<int>();
            test.AddElement(5);
            test.AddElement(6);
            test.AddElement(7);
            test.AddElement(8);
            test.AddElement(9);

            //testing method add
            Console.WriteLine(test);
            //testing insert method
            Console.WriteLine("Insert element 2 at position 4");
            test.InsertElement(4, 2);
            Console.WriteLine(test);
            //testing method remove
            Console.WriteLine("Removing element at pos 5");
            test.RemoveAtIndex(5);
            Console.WriteLine(test);
            int result = test.AccessElement(3);
            Console.WriteLine("Accessing element at index 3: ");
            Console.WriteLine(result);
            Console.WriteLine("Finding element by value '0': ");
            Console.WriteLine(test.FindElementByValue(0));

            Console.WriteLine("Clear!");
            test.ClearingList();
            Console.WriteLine(test);
            Console.WriteLine();
            Console.WriteLine("Doubling the size:");
            for (int i = 1; i < 15; i++)
            {
                test.AddElement(i);
            }
            //test.AddElement(1);
            Console.WriteLine(test);
            //testing min max
            Console.WriteLine("Biggest, smallest: ");
            Console.WriteLine(test.Max<int>());
            Console.WriteLine(test.Min<int>());
        }
开发者ID:joro1881,项目名称:CSharpProgramming,代码行数:41,代码来源:ValidationUnit.cs

示例8: RemovingElementTest

 public void RemovingElementTest()
 {
     GenericList<string> generic = new GenericList<string>(2);
     generic.AddElement("Pesho");
     generic.AddElement("Gosho");
     generic.RemoveAtIndex(1);
     Assert.AreEqual("[Pesho, (null)]", generic.ToString());
 }
开发者ID:abaditsegay,项目名称:SVN,代码行数:8,代码来源:UnitTest1.cs

示例9: Main

        // Some simple tests. They are OPTINAL.
        public static void Main()
        {
            // Create an integer list and add few elements. Also prints the size after each add.
            GenericList<int> list1 = new GenericList<int>(1);

            Console.WriteLine("Type of the list: {0}", list1.GetType());
            Console.WriteLine();

            Console.WriteLine("Current size of the list: {0}", list1.Size);
            Console.WriteLine("Current count of the elements in the list: {0}", list1.Count);
            Console.WriteLine("Adding 1 element...");
            list1.Add(1);
            Console.WriteLine("Current elements in the list:\n{0}", list1.ToString());

            Console.WriteLine("Current size of the list: {0}", list1.Size);
            Console.WriteLine("Current count of the elements in the list: {0}", list1.Count);
            Console.WriteLine("Adding 1 element...");
            list1.Add(2);
            Console.WriteLine("Current elements in the list:\n{0}", list1.ToString());

            Console.WriteLine("Current size of the list: {0}", list1.Size);
            Console.WriteLine("Current count of the elements in the list: {0}", list1.Count);
            Console.WriteLine("Adding 1 element...");
            list1.Add(3);
            Console.WriteLine("Current elements in the list:\n{0}", list1.ToString());

            Console.WriteLine("Current size of the list: {0}", list1.Size);
            Console.WriteLine("Current count of the elements in the list: {0}", list1.Count);
            Console.WriteLine();

            // Print the maximal element
            Console.WriteLine("Maximal element:");
            Console.WriteLine(list1.Max());
            Console.WriteLine();

            // Print an element by it's index
            Console.WriteLine("Printing the element at position 1 (starting from 0):\n{0}", list1[1].ToString());
            Console.WriteLine();

            // Remove an element by it's index
            Console.WriteLine("Removing the element at position 1 (starting from 0)\nand printing the result:");
            list1.RemoveAtIndex(1);

            Console.WriteLine();
            Console.WriteLine("Current size of the list: {0}", list1.Size);
            Console.WriteLine("Current count of the elements in the list: {0}", list1.Count);
            Console.WriteLine("Current elements in the list:\n{0}", list1.ToString());
            Console.WriteLine();

            // Clearing the list (the size won't change)
            Console.WriteLine("Clearing the list...");
            list1.Clear();
            Console.WriteLine("Current size of the list: {0}", list1.Size);
            Console.WriteLine("Current count of the elements in the list: {0}", list1.Count);
            Console.WriteLine("Current elements in the list:\n{0}", list1.ToString());
            Console.WriteLine();

            // Inserting an element at position 0. This will throw an exeption
            // because you can't use InsertAtIndex for empty list.
            Console.WriteLine("Exception will be thrown now...");
            list1.InsertAtIndex(0, 5);
        }
开发者ID:TishoAngelov,项目名称:TelerikAcademy,代码行数:63,代码来源:GenericListTEST.cs

示例10: Main

        static void Main()
        {
            var intList = new GenericList<int>(2);

            Console.WriteLine("Creating an int generic list of length 2");
            Console.WriteLine(new string('-', 30));
            Console.WriteLine("Number of elements: {0}", intList.Count);
            Console.WriteLine("Length: {0}", intList.Length);

            intList.Add(3);
            intList.Add(5);
            Console.WriteLine(new string('-', 30));
            Console.WriteLine("Adding 2 elements.");
            Console.WriteLine(new string('-', 30));
            Console.WriteLine("Number of elements: {0}", intList.Count);
            Console.WriteLine("Length: {0}", intList.Length);
            Console.WriteLine();
            Console.WriteLine("Elements:");
            Console.WriteLine(intList.ToString());

            intList.Add(7);
            Console.WriteLine(new string('-', 30));
            Console.WriteLine("Adding another element.");
            Console.WriteLine(new string('-', 30));
            Console.WriteLine("Number of elements: {0}", intList.Count);
            Console.WriteLine("Length: {0}", intList.Length);
            Console.WriteLine();
            Console.WriteLine("Elements:");
            Console.WriteLine(intList.ToString());

            intList.Clear();
            Console.WriteLine(new string('-', 30));
            Console.WriteLine("Clearing list.");

            intList.InsertAt(0, 2);
            intList.InsertAt(0, 2);
            intList.InsertAt(1, 3);
            Console.WriteLine(new string('-', 30));
            Console.WriteLine("Inserting elements.");
            Console.WriteLine(new string('-', 30));
            Console.WriteLine("Number of elements: {0}", intList.Count);
            Console.WriteLine("Length: {0}", intList.Length);
            Console.WriteLine();
            Console.WriteLine("Elements:");
            Console.WriteLine(intList.ToString());

            intList.RemoveAtIndex(0);
            Console.WriteLine(new string('-', 30));
            Console.WriteLine("Removing an element.");
            Console.WriteLine(new string('-', 30));
            Console.WriteLine("Number of elements: {0}", intList.Count);
            Console.WriteLine("Length: {0}", intList.Length);
            Console.WriteLine();
            Console.WriteLine("Elements:");
            Console.WriteLine(intList.ToString());

            var element  = intList.ElementAt(0);
            Console.WriteLine(new string('-', 30));
            Console.WriteLine("Element at index 0 is {0}.", element);

            element = intList.IndexOf(3);
            Console.WriteLine(new string('-', 30));
            Console.WriteLine("The index of element 3 is {0}.", element);

            var max = intList.Max();
            Console.WriteLine(new string('-', 30));
            Console.WriteLine("The max element is {0}.", max);

            var min = intList.Min();
            Console.WriteLine(new string('-', 30));
            Console.WriteLine("The min element is {0}.", min);

        }
开发者ID:Vyara,项目名称:Telerik-Academy,代码行数:73,代码来源:GenericListTest.cs


注:本文中的GenericList.RemoveAtIndex方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。