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


C# GenericList.Remove方法代码示例

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


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

示例1: Main

 static void Main()
 {
     GenericList<Decimal> testGenList = new GenericList<decimal>();
     testGenList.Add(125.53M);
     testGenList.Add(123);
     testGenList.Add(100);
     testGenList.Add(1000);
     testGenList.Add(10000);
     Console.WriteLine(testGenList.ToString());
     Console.WriteLine(testGenList.Find(100));
     Console.WriteLine(testGenList.Access(1));
     Console.WriteLine(testGenList.Capacity);
     testGenList.Insert(0, 0);
     testGenList.Insert(5, 3);
     testGenList.Remove(testGenList.Count - 1);
     Console.WriteLine(testGenList.ToString());
     testGenList.Insert(16.16M, testGenList.Count - 1);
     testGenList.Insert(17.17M, testGenList.Count - 1);
     testGenList.Insert(18.18M, testGenList.Count - 1);
     testGenList.Insert(19.19M, testGenList.Count - 1);
     Console.WriteLine(testGenList.ToString());
     Console.WriteLine(testGenList.Max());
     testGenList.Remove(testGenList.Find(testGenList.Max()));
     Console.WriteLine(testGenList.ToString());
     Console.WriteLine(testGenList.Max());
     Console.WriteLine(testGenList.Min());
     testGenList.Remove(0);
     Console.WriteLine(testGenList.Min());
     testGenList.Clear();
     Console.WriteLine(testGenList.ToString());
 }
开发者ID:p0150n,项目名称:TelerikAcademy,代码行数:31,代码来源:GenericListTest.cs

示例2: Main

        static void Main()
        {
            GenericList<string> glist = new GenericList<string>();
            glist.Add("First");
            glist.Add("Second");
            glist.Add("Third");
            glist.Add("Pesho");
            glist.Add("Gosho");
            glist.Add("Tosho");

            glist.Insert(0, "Purvi Pesho");

            Console.WriteLine(glist);
            Console.WriteLine("Index of \"Second\": {0}", glist.IndexOf("Second"));
            Console.WriteLine("Does contain \"Toshkata\": {0}", glist.Contains("Toshkata"));
            Console.WriteLine("Does contain \"Pesho\": {0}", glist.Contains("Pesho"));

            Console.WriteLine();

            glist.Remove(2);
            glist.Remove(2);

            Console.WriteLine(glist);
            Console.WriteLine("Min Value: {0}", glist.Min());
            Console.WriteLine("Max Value: {0}", glist.Max());

            glist.Clear();

            Console.WriteLine(glist);
        }
开发者ID:hristodobrev,项目名称:Software-University,代码行数:30,代码来源:GenericListManipulation.cs

示例3: Main

        static void Main()
        {
            var doubleList = new GenericList<double>();

            doubleList.Add(5.5);
            doubleList.Add(6.9);
            doubleList.Add(6.4);
            doubleList.Add(6.7);
            doubleList.Add(5.6);

            int count = doubleList.Count;
            double max = doubleList.Max();
            double min = doubleList.Min();

            Console.WriteLine(doubleList);
            Console.WriteLine("Max: {0}; Min: {1}; Count: {2}", max, min, count);

            doubleList.Remove(6.4);
            doubleList.Remove(5.5);
            doubleList.RemoveAt(1);

            count = doubleList.Count;
            max = doubleList.Max();
            min = doubleList.Min();

            Console.WriteLine(doubleList);
            Console.WriteLine("Max: {0}; Min: {1} Count: {2}", max, min, count);
            doubleList.Version();

            doubleList.Clear();
            bool isEmpty = doubleList.isEmpty;
            Console.WriteLine(isEmpty);
            Console.WriteLine(doubleList);

            var stringList = new GenericList<string>();

            stringList.Add("Kircho");
            stringList.Add("Jecho");
            stringList.Add("Mecho");
            stringList.Add("Vulcho");

            bool jecho = stringList.Contais("Jecho");
            bool nencho = stringList.Contais("Nencho");

            string who = stringList.ElementOf(0);
            int index = stringList.IndexOf("Vulcho");
            string maxString = stringList.Max();

            Console.WriteLine(stringList);
            Console.WriteLine("jecho: {0} \nnencho: {1} \nElement of 0 index: {2} \nIndex of Vulcho: {3} \nMax: {4}"
                , jecho, nencho, who, index, maxString);

            string indexer = stringList[3];
            Console.WriteLine(indexer);

            stringList.Insert("Gocho",2);
            Console.WriteLine(stringList[2]);
            stringList.Version();
        }
开发者ID:alvelchev,项目名称:SoftUni,代码行数:59,代码来源:GenericListMain.cs

示例4: Main

        public static void Main()
        {
            //Test for strings
            Console.WriteLine("Enter capacity for the list of strings");
            long capacity = long.Parse(Console.ReadLine());
            GenericList<string> listStrings = new GenericList<string>(capacity);

            listStrings.Add("Gosho");    //0
            listStrings.Add("Pesho");    //1
            listStrings.Add("Ivan");     //2
            listStrings.Add("Andrei");   //3
            listStrings.Add("Niki");     //4
            listStrings.Add("Svetlin");  //5
            Console.WriteLine(listStrings.ToString()); //Printing the list
            //Remove the element at position 0 and then move the list
            //Do the same with with 2 and then add to the position 3  a new string
            listStrings.Remove(0);
            listStrings.Remove(2);
            listStrings[3] = "Doncho";
            Console.WriteLine(listStrings.ToString()); //Printing the list
            string key = "Svetlin";
            Console.WriteLine("The string '{0}' is on position {1} on the list ", key, listStrings.FindIndex(key));
            Console.WriteLine("The min value is {0}", listStrings.Min());
            Console.WriteLine("The max value is {0}", listStrings.Max());
            listStrings.Clear();
            Console.WriteLine(listStrings.ToString()); //Printing the list
            Console.WriteLine();

            //Test with doubles
            Console.WriteLine("Enter capacity for the list of doubles");
            capacity = long.Parse(Console.ReadLine());
            GenericList<double> listDoubles = new GenericList<double>(capacity);
            listDoubles.Add(5.632);  //0
            listDoubles.Add(123.45); //1
            listDoubles.Add(-34.213);//2
            listDoubles.Add(43.1);   //3
            listDoubles.Add(4.1);    //4
            listDoubles.Add(3.1415); //5
            listDoubles.Add(2.71);   //6
            Console.WriteLine(listDoubles.ToString()); //Printing the list
            //Remove the element at position 0 and then move the list
            //Do the same with with 3 and then add to the position 3  a new string
            listDoubles.Remove(1);
            listDoubles.Remove(3);
            listDoubles[4] = 5.1;
            Console.WriteLine(listDoubles.ToString()); //Printing the list
            double key2 = 3.1415;
            Console.WriteLine("The string '{0}' is on position {1} on the list ", key2, listDoubles.FindIndex(key2));
            Console.WriteLine("The min value is {0}", listDoubles.Min());
            Console.WriteLine("The max value is {0}", listDoubles.Max());
            listDoubles.Clear();
            Console.WriteLine(listDoubles.ToString()); //Printing the list
        }
开发者ID:NikolayGenov,项目名称:TelerikAcademy,代码行数:53,代码来源:TestList.cs

示例5: Main

 static void Main()
 {
     GenericList<int> test = new GenericList<int>(10);
     for (int i = 0; i < test.Length; i++)
     {
         test.Add(i);
     }
     Console.WriteLine(test.ToString());
     test.Remove(9);
     Console.WriteLine(test.ToString());
     test.Insert(9, 9);
     Console.WriteLine(test);
     GenericList<int> newTest = new GenericList<int>(10);
     for (int i = 0; i < newTest.Length - 1; i++)
     {
         newTest.Add(i);
     }
     Console.WriteLine(newTest);
     newTest.Insert(10, 9);
     Console.WriteLine(newTest);
     newTest.Clear();
     Console.WriteLine(newTest);
     Console.WriteLine(test[3]);
     GenericList<string> stringTest = new GenericList<string>(10);
     for (int i = 0; i < stringTest.Length - 2; i++)
     {
         stringTest.Add(i.ToString());
     }
     Console.WriteLine(stringTest);
     stringTest.Add("huehuehueheuhe");
     Console.WriteLine(stringTest);
     stringTest.Insert("Teehee", 9);
     Console.WriteLine(stringTest);
 }
开发者ID:NasC0,项目名称:Telerik_Homework,代码行数:34,代码来源:GenericListTest.cs

示例6: Main

        public static void Main()
        {
            Console.Title = "Problem 3.	Generic ";

            GenericList<int> numbers = new GenericList<int>();
            numbers.Add(5);
            numbers.Add(50);
            numbers.Add(500);
            numbers.Add(1000);

            Console.WriteLine(numbers.Max());
            Console.WriteLine(numbers.Min());

            Console.WriteLine(numbers.GetAtIndex(1));
            numbers.Insert(1, 25);
            Console.WriteLine(numbers.IndexOf(50));
            Console.WriteLine(numbers.Contains(5));
            numbers.Remove(5);
            Console.WriteLine(numbers);
            numbers.Clear();
            Console.WriteLine(numbers);

            Console.WriteLine();
            Console.WriteLine("Problem 4.	Generic List Version");
            System.Reflection.MemberInfo info = typeof(GenericList<>);
            foreach (object attribute in info.GetCustomAttributes(false))
            {
                Console.WriteLine(attribute);
            }
        }
开发者ID:Nezhdetov,项目名称:Software-University,代码行数:30,代码来源:GenericListMain.cs

示例7: Main

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

        intList.Add(1);
        intList.Add(2);
        intList.Add(3);
        intList.Add(4);
        intList.Add(5);
        Console.WriteLine("Number of elements: {0}", intList.Count);
        Console.WriteLine(intList);
        intList[4] = 133;
        Console.WriteLine(intList);

        intList.Remove(2);
        Console.WriteLine(intList);

        intList.Insert(0, 4);
        Console.WriteLine(intList);

        Console.WriteLine(intList.Find(133));

        Console.WriteLine(intList.Contains(4));

        Console.WriteLine("Max = " + intList.Max());
        Console.WriteLine("Min = " + intList.Min());

        intList.Clear();
        Console.WriteLine("Elemets in List: " + intList.Count);

        Type type = typeof(GenericList<>);
        object[] allAttributes = type.GetCustomAttributes(typeof(VersionAttribute), false);
        Console.WriteLine("GenericsList's version is {0}", ((VersionAttribute)allAttributes[0]).Version);
    }
开发者ID:GeorgiLambov,项目名称:SoftwareUniversity,代码行数:34,代码来源:GenericListTest.cs

示例8: Main

        static void Main(string[] args)
        {
            Console.WriteLine("GenericList Task\r\n");

            GenericList<string> list = new GenericList<string>("first", "second", "third", "fourth", "fifth", "sixth", "seventh", "eight");
            Console.WriteLine(list);

            list[3] = "fourth changed";
            list.Add("nineth");
            list.Insert(0, "zero");
            list.Remove(5);
            Console.WriteLine("Modified list(indexed access, add, insert, remove):\r\n" + list);

            int found = list.Find("second");
            Console.WriteLine("Search for 'second': index={0}, element={1}", found, list[found]);
            found = list.Find("bla");
            Console.WriteLine("Search for 'bla': index={0}", found);

            Console.WriteLine("Min element: " + list.Min());
            Console.WriteLine("Max element: " + list.Max());

            list.Clear();
            Console.WriteLine("Clearing list: " + list);

            Console.WriteLine("\r\nPress Enter to finish");
            Console.ReadLine();
        }
开发者ID:psotirov,项目名称:TelerikAcademyProjects,代码行数:27,代码来源:GenericListTest.cs

示例9: Main

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

        for (int i = 0; i < 25; i++)
        {
            test.Add(i * 4);
        }

        Console.WriteLine(test);

        test.Remove(5);

        Console.WriteLine(test);

        test.Insert(9, 77);
        Console.WriteLine(test);

        Console.WriteLine("ByValue: {0} ", test.FindIndexByValue(77));
        Console.WriteLine("ByIndex: {0}", test[17]);
        Console.WriteLine("Max: {0} ", test.GetMax());
        Console.WriteLine("Min: {0}" , test.GetMin());

        test.Clear();
    }
开发者ID:RuParusheva,项目名称:TelerikAcademy,代码行数:25,代码来源:Test.cs

示例10: Main

 static void Main(string[] args)
 {
     var listtt = new List<int>();
     GenericList<int> myList = new GenericList<int>(10);
     //ADD
     myList.Add(1);
     myList.Add(2);
     myList.Add(3);
     Console.WriteLine(myList.ToString());
     Console.WriteLine("Insert element");
     //INSERT AT GIVEN POSITION
     myList.Insert(3, 50);
     myList.Insert(3, 60);
     Console.WriteLine(myList.ToString());
     Console.WriteLine("Find element:");
     //FIND CERTAINT ELEMENT AT WHAT INDEXES EXISTS
     myList.Find(25);
     Console.WriteLine("Remove element:");
     //REMOVE AT CERTAIN INDEX
     myList.Remove(2);
     Console.WriteLine(myList.ToString());
     Console.WriteLine("Find maximum");
     //FIND MAX
     Console.WriteLine(myList.Max());
     Console.WriteLine("Find minimum");
     //FIND MIN
     Console.WriteLine(myList.Max());
     //CLEAR ALL
     Console.WriteLine("Clear all");
     myList.Clear();
     Console.WriteLine(myList.ToString());
 }
开发者ID:AYankova,项目名称:Telerik-Academy-HW,代码行数:32,代码来源:Test.cs

示例11: Main

        static void Main()
        {
            GenericList<string> names = new GenericList<string>();
            names.ShowVersion();

            names.Add("Gosho");
            names.Add("Pesho");
            names.Add("Misho");
            names.Add("Tisho");
            names.Add("Nashmat");
            names.Add("Onufri");
            names.Add("Gencho");

            names.Insert("Tyanko", 2);
            names.Remove(1);
            //names.Clear();

            names.Add("Asen");
            names.Add("Zaro");

            Console.WriteLine("All elements: " + names);
            Console.WriteLine("Max element: " + names.Max());
            Console.WriteLine("Min element: " + names.Min());

            string search = "Onufri";
            Console.WriteLine("Elements contain {0}: {1}", search, names.Contains(search));
            Console.WriteLine("Index of {0}: {1}", search, names.IndexOf(search));
        }
开发者ID:AsenTahchiyski,项目名称:SoftUni,代码行数:28,代码来源:Program.cs

示例12: Main

        static void Main()
        {
            GenericList<int> test = new GenericList<int>(2);
            test.Add(1);
            test.Add(2);
            test.Add(10);
            test.Add(99);
            test.Add(22);
            test.Add(40);
            test.Add(121);
            test.Add(23);
            Console.WriteLine(test);
            Console.WriteLine(test[3]);
            Console.WriteLine(test.IndexOf(121));
            test.Remove(3);
            Console.WriteLine(test);
            Console.WriteLine(test[3]);
            Console.WriteLine(test.IndexOf(121));
            test.Insert(66, 4);
            Console.WriteLine(test);
            test.Insert(66, 4);
            Console.WriteLine(test);
            Console.WriteLine(test.Count);
            Console.WriteLine("Max: " + test.Max());
            Console.WriteLine("Min: " + test.Min());

            Console.WriteLine(test.Contains(121));

            Console.WriteLine();
            var allAttributes = typeof(GenericList<>).GetCustomAttributes(typeof(VersionAttribute), false);
            Console.WriteLine("Version: " + allAttributes[0]);
        }
开发者ID:ScreeM92,项目名称:Software-University,代码行数:32,代码来源:GenericListTest.cs

示例13: Main

        static void Main(string[] args)
        {
            GenericList<int> test = new GenericList<int>(1);
            test.Add(2);
            test.Add(45);
            test.Add(4);
            test.Add(50);
            test.Add(0);
            test.Add(-1000);

            Console.WriteLine(test);

            test.Remove(4);

            Console.WriteLine(test);

            test.Insert(0, 560);

            Console.WriteLine(test);

            Console.WriteLine(test.Find(123));

            Console.WriteLine(test.Max());
            Console.WriteLine(test.Min());

            test.Clear();

            Console.WriteLine(test);
        }
开发者ID:nikolaZ,项目名称:TelerikAcademy,代码行数:29,代码来源:Program.cs

示例14: Main

        static void Main(string[] args)
        {
            var list = new GenericList<int>();
            list.Add(1);
            list.Add(2);
            list.Add(3);
            list.Add(4);
            list.Add(5);
            list.Add(6);
            list.Add(7);
            list.Add(8);
            list.Add(9);
            list.Add(10);
            list.Add(11);
            list.Add(12);
            list.Add(13);
            list.Add(14);
            list.Add(15);
            list.Add(16);
            list.Add(17);

            list.Remove(0);
            Console.WriteLine(list[12]);
            Console.WriteLine(list[13]);
            Console.WriteLine(list[14]);
            Console.WriteLine(list[15]);

            list.Insert(5, 0);

            Console.WriteLine(list);
        }
开发者ID:teodory,项目名称:SoftUni-Homeworks,代码行数:31,代码来源:MainProgram.cs

示例15: Main

        public static void Main()
        {
            //5 Write a generic class GenericList<T> that keeps a list of elements of some parametric type T.
            //Keep the elements of the list in an array with fixed capacity which is given as parameter in the class constructor.
            //Implement methods for adding element, accessing element by index, removing element by index,
            //inserting element at given position, clearing the list, finding element by its value and ToString().
            //Check all input parameters to avoid accessing elements at invalid positions.
            GenericList<int> testList = new GenericList<int>(3);
            testList.Add(2);
            testList.Add(3);
            testList.Add(4);
            testList.Remove(3);

            //6 Implement auto-grow functionality: when the internal array is full,
            //create a new array of double size and move all elements to it.
            GenericList<char> growList = new GenericList<char>(2);
            testList.Add('a');
            testList.Add('b');
            testList.Add('c');
            testList.Add('d');
            testList.Add('e');

            //7 Create generic methods Min<T>() and Max<T>() for finding the minimal and maximal element in the GenericList<T>.
            //You may need to add a generic constraints for the type T.
            GenericList<int> comearableList = new GenericList<int>();
            comearableList.Add(1);
            comearableList.Add(4);
            comearableList.Add(1321);
            Console.WriteLine("The biggest element in Comearable List is:");
            Console.WriteLine(comearableList.Max());
        }
开发者ID:slop3n,项目名称:TelerikAcademy,代码行数:31,代码来源:TestingMain.cs


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