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


C# GenericList.Max方法代码示例

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


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

示例3: Main

 static void Main()
 {
     Console.WriteLine("Hello World.");
     Console.WriteLine("Make new List.");
     GenericList<float> newList = new GenericList<float>(20);
     Console.WriteLine("Add some numbers to the List - 5.3, 6.27, 7.55, 8, 9.09");
     newList.AddElement(5.3f);
     newList.AddElement(6.27f);
     newList.AddElement(7.55f);
     newList.AddElement(8f);
     newList.AddElement(9.09f);
     Console.WriteLine("Print Max element: {0}", newList.Max());
     Console.WriteLine("Print Min element: {0}", newList.Min());
     Console.WriteLine("Add 10 in the biggining.");
     newList.InsertElement(0, 10);
     Console.WriteLine("Print Max element again: {0}", newList.Max());
     Console.WriteLine("Print the List.");
     Console.WriteLine(newList);
     Console.WriteLine("Remove the fourth element.");
     newList.RemoveElement(3);
     Console.WriteLine("Print the List.");
     Console.WriteLine(newList);
     Console.WriteLine("Remove the fourth element.");
     newList.RemoveElement(3);
     Console.WriteLine("Print the List.");
     Console.WriteLine(newList);
     Console.WriteLine("Remove the fourth element.");
     newList.RemoveElement(3);
     Console.WriteLine("Print the List.");
     Console.WriteLine(newList);
     Console.WriteLine("Add 15.56 in the end.");
     newList.InsertElement(3, 15.56f);
     Console.WriteLine("Print the List.");
     Console.WriteLine(newList);
 }
开发者ID:Nikolai-Aleksiev,项目名称:Telerik-Academy-HomeWorks,代码行数:35,代码来源:GenericTest.cs

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

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

示例6: Main

 static void Main()
 {
     //Some tests. You can change values to check the correct work of the program.
     GenericList<int> sampleList = new GenericList<int>(5);
     sampleList.AddToGenericList(7);
     sampleList.AddToGenericList(5);
     sampleList.AddToGenericList(1);
     sampleList.AddToGenericList(70);
     sampleList.AddToGenericList(-7);
     string listElements = sampleList.ToString();
     Console.WriteLine("Sample list: {0}", listElements);
     int element = sampleList.AcessByIndex(1);
     Console.WriteLine("The value of the element on index 1 is {0}", element);
     sampleList.RemoveByIndex(1);
     Console.WriteLine("Sample list: {0}", sampleList);
     sampleList.InsertAtPosition(2, 222);
     Console.WriteLine("Sample list: {0}", sampleList);
     int index = sampleList.FindByValue(70);
     Console.WriteLine("1 is on index {0}", index);
     int min = sampleList.Min();
     int max = sampleList.Max();
     Console.WriteLine("Min value - {0} \nMax value - {1}", min, max);
     sampleList.ClearingList();
     Console.WriteLine("Sample list: {0}", sampleList);
 }
开发者ID:PavDragneva,项目名称:TelerikAcademy,代码行数:25,代码来源:Start.cs

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

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

示例9: Main

        static void Main(string[] args)
        {
            Console.WriteLine(typeof(GenericList<>).GetCustomAttribute(typeof(Ver)));

            GenericList<string> list = new GenericList<string>();
            GenericList<Point2D> list2 = new GenericList<Point2D>();
            list2.Add(new Point2D(5, 3));
            list2.Add(new Point2D(6, 4));

            list.Add("az");
            list.Add("ti");
            list.Add("toj");
            list.Add("tq");
            list.Insert("to",1);
            list.Remove(3);

            for (int i = 0; i < list.Count; i++)
            {
                Console.WriteLine(list[i]);
            }

            Console.WriteLine(Environment.NewLine);
            Console.WriteLine(list.FindIndexOf("toj"));
            Console.WriteLine(list);
            Console.WriteLine(list.Contains("tq"));
            Console.WriteLine(list.Max());
            Console.WriteLine(list2.Max());
            Console.WriteLine(list2.Contains(new Point2D(5, 3)));
            Console.WriteLine(list2.Contains(new Point2D(5, 2)));
        }
开发者ID:EBojilova,项目名称:SoftUni-3,代码行数:30,代码来源:Program.cs

示例10: Main

    public 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.RemoveAt(3);
        Console.WriteLine(test);
        Console.WriteLine(test[3]);
        Console.WriteLine(test.IndexOf(121));
        test.InsertAt(4, 66);
        Console.WriteLine(test);
        Console.WriteLine(test.Count);
        Console.WriteLine("Max: " + test.Max());
        Console.WriteLine("Min: " + test.Min());

        Console.WriteLine();
        //var allAttributes = typeof(GenericList<>).GetCustomAttributes(typeof(VersionAttribute), false);
        //Console.WriteLine("Version: " + allAttributes[0]);
    }
开发者ID:zhanivanov,项目名称:OOP_September_Homeworks,代码行数:28,代码来源:GenericListExample.cs

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

示例12: Main

    public static void Main()
    {
        GenericList<int> listTesting = new GenericList<int>(1);
        listTesting.AddElement(2);
        listTesting.AddElement(3);
        listTesting.AddElement(4);
        listTesting.AddElement(5);
        listTesting.AddElement(6);
        listTesting.AddElement(-1000);

        Console.WriteLine(listTesting);

        listTesting.RemoveElemAtIndex(4);

        Console.WriteLine(listTesting);

        listTesting.InsertElemAtIndex(0, 123);

        Console.WriteLine(listTesting);

        Console.WriteLine(listTesting.FindElemByValue(123));

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

        listTesting.ClearList();

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

示例13: Main

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

            list.Add(0);
            list.Add(1);
            //Console.WriteLine(list[2]);

            list.Insert(1, 4);
            list[0] = 2;
            list[2] = 3;
            //list[3] = 3;

            Console.Write("Accessing by index (list[1]): ");
            Console.ForegroundColor = ConsoleColor.Yellow;
            Console.WriteLine(list[1]);
            Console.ForegroundColor = ConsoleColor.Gray;

            Console.Write("ToString(): ");
            Console.ForegroundColor = ConsoleColor.Yellow;
            Console.WriteLine(list.ToString());
            Console.ForegroundColor = ConsoleColor.Gray;

            Console.Write("Min<int>(): ");
            Console.ForegroundColor = ConsoleColor.Yellow;
            Console.WriteLine(list.Min<int>());
            Console.ForegroundColor = ConsoleColor.Gray;

            Console.Write("Max<int>(): ");
            Console.ForegroundColor = ConsoleColor.Yellow;
            Console.WriteLine(list.Max<int>());
            Console.ForegroundColor = ConsoleColor.Gray;
        }
开发者ID:Velmond,项目名称:TelerikAcademy-CSharp,代码行数:33,代码来源:TestApplication.cs

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

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


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