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


C# GenericList.FindElementByValue方法代码示例

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


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

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

示例2: Main

        static void Main()
        {
            GenericList<int> test = new GenericList<int>(5);
            test.Add(56);
            test.Add(56);
            test.Add(56);
            test.Add(56);
            test.Add(56);
            test.Add(56);
            GenericList<string> test2 = new GenericList<string>(10);
            test2.Add("asdasda");
            test2.Add("sadasdsd");
            test2.RemoveElement(0);
            Console.WriteLine(test2.ElementByIndex(0));
            test.InsertAt(2, 57);
            Console.WriteLine(test.FindElementByValue(57));
            int t = GenericList<GenericList<string>>.Min<int>(67, 68);
            Console.WriteLine(t);

            //GenericList<int> testList = new GenericList<int>();
            //GenericList<string> testList2 = new GenericList<string>();
            //testList.Add(56);
            //Tuple<int, string> test = new Tuple<int, string>(5, "az");
            //Console.WriteLine(test.Item2);
            //int a = 5;
            //int b = 6;
            //int min = Max<int>(a, b);
            //Console.WriteLine(min);
        }
开发者ID:stefan-petrov,项目名称:TelerikAcademy,代码行数:29,代码来源:Test.cs

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

示例4: Main

    public static void Main()
    {
        //testing bellow all of the defined in GenericList
        GenericList<int> listTesting = new GenericList<int>(1);
        listTesting.AddElement(3);
        listTesting.AddElement(2);
        listTesting.AddElement(-100);
        listTesting.AddElement(1);
        listTesting.AddElement(6);

        Console.WriteLine(listTesting);

        listTesting.RemoveElementAtIndex(1);

        Console.WriteLine(listTesting);

        listTesting.InsertElementAtIndex(0, 21);

        Console.WriteLine(listTesting);

        Console.WriteLine(listTesting.FindElementByValue(7));

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

        listTesting.ClearList();

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

示例5: Main

        static void Main()
        {
            int size = 5;
            GenericList<int> integerNum = new GenericList<int>(size);

            //adding element
            for (int i = 0; i < integerNum.ArraySize; i++)
            {
                integerNum.Add(i + 5);
            }

            //add size + 1 element to generate error
            //integerNum.Add(135);

            //removing element by index
            integerNum.DeleteByIndex(1);
            Console.WriteLine(integerNum.ToString());

            //insert element
            integerNum.InsertAtPosition(7, 59999);
            Console.WriteLine(integerNum.ToString());

            //clear
            integerNum.Clear();
            Console.WriteLine(integerNum.ToString());
            integerNum.Add(78);

            //finding element by its value
            integerNum.Add(78);
            integerNum.Add(15);
            integerNum.Add(450);

            Console.WriteLine(integerNum.FindElementByValue(6));
            Console.WriteLine(integerNum.FindElementByValue(78));

            //ToString()
            Console.WriteLine(integerNum.ToString());
        }
开发者ID:ralikuman,项目名称:TelerikAcademy,代码行数:38,代码来源:GenericListExample.cs

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

示例7: Main

        static void Main(string[] args)
        {
            Console.WriteLine("*********");
            Console.WriteLine("POINT 3D:");
            Console.WriteLine("*********");
            Point3D testPoint1 = new Point3D(5, 6, 7);
            Point3D testPoint2 = new Point3D(6, 7, 9);
            Console.WriteLine("Point1: {0}", testPoint1);
            Console.WriteLine("Point2: {0}", testPoint2);
            Console.WriteLine("Distance: {0}", Distance3D.Distance(testPoint1, testPoint2));
            Console.WriteLine();
            Console.WriteLine("**************");
            Console.WriteLine("GENERIC CLASS:");
            Console.WriteLine("**************");
            GenericList<int> testList = new GenericList<int>(2);
            testList.AddElement(1);
            testList.AddElement(2);
            testList.AddElement(3);
            testList.AddElement(4);
            testList.AddElement(5);
            testList.InsertElementAtGivenPosition(6, 1);
            testList.RemoveElementByIndex(0);
            Console.WriteLine(testList);
            Console.WriteLine("Position of 4: {0}", testList.FindElementByValue(4));
            Console.WriteLine("Max element: {0}", testList.Max());
            Console.WriteLine("Min element: {0}", testList.Min());
            Console.WriteLine("Count: {0}", testList.Count);
            Console.WriteLine("Capacity: {0}", testList.Capacity);
            testList.ClearList();
            testList.AddElement(800);
            Console.WriteLine(testList);
            Console.WriteLine();
            Console.WriteLine("*************");
            Console.WriteLine("MATRIX CLASS:");
            Console.WriteLine("*************");
            Matrix<int> m1 = new Matrix<int>(3, 3);
            Matrix<int> m2 = new Matrix<int>(3, 3);
            // Fill with random numbers
            Random randomGenerator = new Random();
            for (int i = 0; i < m1.Rows; i++)
            {
                for (int j = 0; j < m1.Columns; j++)
                {
                    m1[i, j] = randomGenerator.Next(20);
                    m2[i, j] = randomGenerator.Next(20);
                }
            }
            Console.WriteLine("Matrix 1");
            Console.WriteLine(m1);
            Console.WriteLine("Matrix 2");
            Console.WriteLine(m2);
            Console.WriteLine("Matrix 1 + Matrix 2");
            Console.WriteLine(m1 + m2);
            Console.WriteLine("Matrix 1 - Matrix 2");
            Console.WriteLine(m1 - m2);
            Console.WriteLine("Matrix 1 * Matrix 2");
            Console.WriteLine(m1 * m2);

            Console.WriteLine("******************");
            Console.WriteLine("VERSION ATTRIBUTE:");
            Console.WriteLine("******************");
            Type type = typeof(DefiningClasses);
            object[] allCustomAttributes = type.GetCustomAttributes(false);
            foreach (VersionAttribute attribute in allCustomAttributes)
            {
                Console.WriteLine("Current version is: {0}", attribute.FullVersion);
            }
        }
开发者ID:vot24100,项目名称:Telerik-Academy-Homeworks,代码行数:68,代码来源:DefiningClasses.cs


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