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


C# GenericList.Min方法代码示例

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


在下文中一共展示了GenericList.Min方法的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()
        {
            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

示例3: 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

示例4: Main

        static void Main()
        {
            GenericList<int> list = new GenericList<int>(5);
            StringBuilder result = new StringBuilder();
            list.Add(3);
            list.InsertAt(0, 2);
            list.InsertAt(0, 1);
            result.AppendLine(list.ToString());
            result.AppendLine(String.Format("Count: {0}", list.Count));

            result.AppendLine("--REMOVE AT INDEX 1--");
            list.RemoveAt(1);
            result.AppendLine(list.ToString());
            result.AppendLine(String.Format("Count: {0}", list.Count));

            result.AppendLine("     MIN: " + list.Min());
            result.AppendLine("     MAX: " + list.Max());

            result.AppendLine("-----INDEX OF 3-----");
            result.AppendLine(list.IndexOf(3).ToString());
            result.AppendLine("-----INDEX OF 2-----");
            result.AppendLine(list.IndexOf(2).ToString());

            result.AppendLine("-----CLEAR LIST-----");
            list.Clear();
            result.AppendLine(list.ToString());
            result.AppendLine(String.Format("Count: {0}", list.Count));

            Console.WriteLine(result);
        }
开发者ID:RuzmanovDev,项目名称:TelerikAcademy,代码行数:30,代码来源:Test.cs

示例5: Main

        static void Main(string[] args)
        {
            GenericList<string> genericList = new GenericList<string>();
            genericList.Add("a");
            genericList.Add("b");
            genericList.Add("c");
            Console.WriteLine(genericList);
            Console.WriteLine("Max = {0}, Min = {1}",genericList.Max(),genericList.Min());
            Console.WriteLine("Remove b");
            genericList.Remove("b");
            Console.WriteLine(genericList);
            Console.WriteLine("genericList[0] = "+genericList.Access(0));
            Console.WriteLine("index of c = "+genericList.FindIndex("c"));
            genericList.Clear();
            genericList.Add("rom");
            genericList.Add("mon");
            genericList.Add("dom");
            Console.WriteLine(genericList);
            Console.WriteLine("Insert zom (index = 1)");
            genericList.Insert("zom",1);
            Console.WriteLine(genericList);
            Console.WriteLine(genericList.Contains("mon"));
            Console.WriteLine(genericList.Contains("aaa"));

            Type type = typeof(GenericList<>);
            object[] allAttributes = type.GetCustomAttributes(typeof(VersionAttribute), false);
            foreach (VersionAttribute attr in allAttributes)
            {
                Console.WriteLine("This class's version is {0}.", attr.Version);
            }
        }
开发者ID:ikolev94,项目名称:Homeworks,代码行数:31,代码来源:Program.cs

示例6: Main

        static void Main()
        {
            GenericList<int> testList = new GenericList<int>(5);
            testList.Add(5);
            testList.Add(45);
            testList.Add(18);
            testList.Add(66);
            testList.Add(22);
            testList.Add(6);
            testList.Add(2);
            testList.Add(9);
            testList.Add(10);

            Console.WriteLine("tstList.Count ->{0}",testList.Count);
            Console.WriteLine(testList.ToString());

            testList.RemoveAt(3);
            Console.WriteLine("After removing an element:");
            Console.WriteLine("tstList.Count ->{0}", testList.Count);
            Console.WriteLine(testList.ToString());

            testList.InsertAt(3, 66);
            Console.WriteLine("After inserting an element:");
            Console.WriteLine("tstList.Count ->{0}", testList.Count);
            Console.WriteLine(testList.ToString());
            Console.WriteLine();
            Console.WriteLine("searching for element:");
            int position=testList.FindByValue(66);
            Console.WriteLine("The element is on position {0}", position);
            position = testList.Min();
            Console.WriteLine("The Min Element in list is {0}",position);
            position = testList.Max();
            Console.WriteLine("The Max Element in list is {0}",position);
        }
开发者ID:kicata,项目名称:OPP,代码行数:34,代码来源:TestGenericListClass.cs

示例7: Main

        static void Main()
        {
            GenericList<int> list = new GenericList<int>(3);
            GenericList<string> listNames = new GenericList<string>(2);

            listNames.Add("Pesho");
            listNames.Add("Avan");
            Console.WriteLine(listNames);
            Console.WriteLine(listNames.Min<string>());

            list.Add(1);
            list.Add(2);
            list.Add(1);

            //list.RemoveElement(2);
            //list.Clear();
            list.Insert(10, 0);
            list.Add(-3);
            list.Add(13);
            list.Add(3);
            list.TakeElement(1);
            Console.WriteLine(list);

            Console.WriteLine(list.FindElement(10));

            list.FindElement(2);

            Console.WriteLine("Minimal value: " + list.Min<int>());
            Console.WriteLine("Maximal value: " + list.Max<int>());
            Console.WriteLine("Capacity: " + list.Capacity);
            Console.WriteLine("Count: " + list.Count);
        }
开发者ID:ilian-ivanov,项目名称:Telerik-Academy,代码行数:32,代码来源:GenericListTest.cs

示例8: Main

    static void Main()
    {
        GenericList<int> nums = new GenericList<int>() { 1, 2, 5, 7 };
        Console.WriteLine("All elements: " + nums.ToString());

        Console.WriteLine("Num at index 1: " + nums[1]);
        nums.Remove(0);
        Console.WriteLine("Element at index 0 has been removed");
        Console.WriteLine("Num at index 1: " + nums[1]);
        Console.WriteLine("The index of 5 is: " + nums.Find(5));
        Console.WriteLine("Nums contains 7? " + nums.Contains(7));
        for (int index = 0; index < 50; index++)
        {
            nums.Add(9);
            Console.Write("Element added: " + nums[nums.Count - 1]);
            Console.WriteLine(" Count: " + nums.Count + " Capacity: " + nums.Capacity);
        }
        nums.Insert(14, 0);
        nums.Insert(14, 0);
        nums.Insert(14, 0);
        nums.Insert(20, 20);
        Console.WriteLine(nums);
        Console.WriteLine("Min: " + nums.Min());
        Console.WriteLine("Max: " + nums.Max());

        Console.WriteLine("The version of this class is: " + nums.Version());
    }
开发者ID:shnogeorgiev,项目名称:Software-University-Courses,代码行数:27,代码来源:GenericListDemo.cs

示例9: Main

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

            Console.WriteLine("Add , auto-grow and ToString() test");
            Console.WriteLine();
            // Testing add method and auto-grow
            for (int i = 1; i <= 20; i++)
            {
                list.Add(i);
            }
            Console.WriteLine(list.ToString());
            AddSeparator();

            // Add 100 on position 5
            Console.WriteLine("Test insert at position (insert 100 on position 5)");
            Console.WriteLine();
            list.Add(100, 5);
            Console.WriteLine(list.ToString());
            AddSeparator();

            // Test min and max
            Console.WriteLine("Min --> {0}", list.Min());
            Console.WriteLine("Max --> {0}", list.Max());
            AddSeparator();

            // Indexer test
            Console.WriteLine("Indexer test:");
            Console.WriteLine("list[5] --> {0}", list[5]);
            AddSeparator();
        }
开发者ID:DareDev1l,项目名称:TelerikAcademy,代码行数:31,代码来源:GenericListTest.cs

示例10: Main

        static void Main()
        {
            GenericList<int> listInt = new GenericList<int>();
            GenericList<string> listString = new GenericList<string>(60);

            listInt.Add(5);
            listInt.Add(6);
            listInt.Add(7);
            listInt.Add(8);

            listString.Add("Generic");
            listString.Add("List");
            int takeElement = listInt.ElementAt(0);

            // list.InsertAt(1, 5);
            // list.RemoveAt(0);
            // list.Clean();
            // int index = list.GetIndex(5);
            // int capacity = list.Capacity;
            // int count = list.Count;

            int min = listInt.Min();
            int max = listInt.Max();

            string minString = listString.Min();
            string maxString = listString.Max();

            Console.WriteLine(listInt);

            Console.WriteLine(listString);
        }
开发者ID:jerko0,项目名称:Telerik-Academy,代码行数:31,代码来源:tastFrom5to7.cs

示例11: 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

示例12: Main

    static void Main()
    {
        GenericList<int> list = new GenericList<int>(5);
        list.Add(1);
        list.Add(3);
        list.Add(5);
        list.Add(7);
        list.Add(9);
        //Console.WriteLine(list);

        //list.FindElementWithValue(2);
        //list.FindElementWithValue(3);
        //Console.WriteLine();

        //list.RemoveElementAtIndex(4);
        //Console.WriteLine(list);

        //list.InsertElementAtIndex(1, 2);
        //list.InsertElementAtIndex(5, 1);
        //Console.WriteLine(list);

        //list.ClearList();
        //Console.WriteLine(list);

        // Min() and Max() Test
        Console.WriteLine(list.Min<int>());
        Console.WriteLine(list.Max<int>());
    }
开发者ID:GStoykov,项目名称:TelerikAcademyHomeworks,代码行数:28,代码来源:Program.cs

示例13: Main

        static void Main()
        {
            GenericList<int> l = new GenericList<int>(1);

            l.Add(1);
            l.Add(2);
            l.Add(3);
            l.Add(4);
            l.Add(5);
            l.Add(-1);

            Console.WriteLine(l);

            l.RemoveAt(5);

            Console.WriteLine(l);

            l.InsertAt(0, -3);

            Console.WriteLine(l);

            Console.WriteLine(l.IndexOf(-3));

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

            l.Clear();

            Console.WriteLine(l);
        }
开发者ID:neofitov,项目名称:TelerikAcademyHomeworks,代码行数:30,代码来源:Test.cs

示例14: Main

        public static void Main()
        {
            Console.WriteLine("> Create new generic list...");
            GenericList<int> list = new GenericList<int>();
            PrintListData(list);

            Console.WriteLine("> Add four items...");
            list = new GenericList<int>(1, 2, 3, 4); // Use the constructor
            PrintListData(list);

            Console.WriteLine("> List is full, add one more item...");
            list.Add(5);
            PrintListData(list);

            Console.WriteLine("> Remove element at index 2...");
            list.RemoveAt(2);
            PrintListData(list);

            Console.WriteLine("> Insert element '3' at index 2...");
            list.InsertAt(3, 2);
            PrintListData(list);

            Console.WriteLine("> Find element '3'...");
            int item = 3;
            int index = list.Find(item);
            Console.WriteLine("Element '{0}' found at index {1}.\n", item, index);

            Console.WriteLine("> Find min and max value...");
            Console.WriteLine("Min: {0}", list.Min());
            Console.WriteLine("Max: {0}\n", list.Max());

            Console.WriteLine(">Clear the list...");
            list.Clear();
            PrintListData(list);
        }
开发者ID:MarKamenov,项目名称:TelerikAcademy,代码行数:35,代码来源:Program.cs

示例15: Main

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

            var attributes = typeof(GenericList<>).GetCustomAttributes(typeof(VersionAttribute), false);
            Console.WriteLine("Version: {0}", ((VersionAttribute)attributes[0]).Version + Environment.NewLine);

            list.AddElement(3);
            list.AddElement(5);
            list.AddElement(12);
            Console.WriteLine("Add elements: {0}", list + Environment.NewLine);

            Console.WriteLine("Get element at index [0] \r\n{0}",
                list[0] + Environment.NewLine);

            list.RemoveElementAtIndex(1);
            Console.WriteLine("Remove element at index [1] \r\n{0}",
                list + Environment.NewLine);

            list.InsertElementAtIndex(2, -3);
            Console.WriteLine("Insert '-3' at index [2] \r\n{0}",
                list + Environment.NewLine);

            Console.WriteLine("Find element '-3' \r\n{0}",
                list.FindElementByValue(-3) + Environment.NewLine);

            Console.WriteLine("STATISTICS \r\nElements count: {0} \r\nMin element: {1} \r\nMax element: {2}",
                list.Count, list.Min(), list.Max() + Environment.NewLine);

            list.ClearList();
            Console.WriteLine("Clear the list \r\nList count: {0}", list.Count);
        }
开发者ID:unbelt,项目名称:SoftUni,代码行数:32,代码来源:GenericListTest.cs


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