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


C# GenericList.FindByValue方法代码示例

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


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

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

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

示例3: Main

        static void Main()
        {
            //GenericList<string> test = new GenericList<string>();
            //test.AddElement("Testing");
            //test.AddElement("string");
            //Console.WriteLine(test.ToString()); //before inserting a new element
            //test.InsertAtIndex(0, "sf");
            //Console.WriteLine(test.ToString());    //after inserting a new element
            //var testAccessByIndex = test.AccessByIndex(1);
            //Console.WriteLine("I am the element at index 1 = {0}", testAccessByIndex);

           GenericList<double> anotherTest = new GenericList<double>();
           anotherTest.AddElement(1);
           anotherTest.AddElement(2);
           anotherTest.AddElement(3);
           anotherTest.AddElement(4);
          
           Console.WriteLine("Numbers = {0}", anotherTest.ToString());
           var minElement = anotherTest.Min();
           Console.WriteLine("MIN element is {0}", minElement);
           var maxElement = anotherTest.Max();
           Console.WriteLine("MAX element is {0}", maxElement);
           Console.WriteLine("Element[1] using indexer = {0}", anotherTest[1]);
           Console.WriteLine("Element AccessByIndex(1) = {0}", anotherTest.AccessByIndex(1));
           anotherTest.RemoveByIndex(1);
           Console.WriteLine("Removed element[1], result = {0}", anotherTest.ToString());
           anotherTest.InsertAtIndex(1, 5);
           Console.WriteLine("Insert 5 at index[1],result = {0}",anotherTest.ToString());
           anotherTest.ClearList();
           Console.WriteLine("Elements ClearList() = {0}", anotherTest.ToString());
           Console.WriteLine("Check if list contains 0: {0}",anotherTest.FindByValue(0));
        }
开发者ID:Alex-Bubblemaster,项目名称:C-Sharp-OOP,代码行数:32,代码来源:TestWithMain.cs

示例4: Main

        public static void Main(string[] args)
        {
            //test GenericList
            Console.WriteLine("Test \"GenericList\"");
            GenericList<int> list = new GenericList<int>(5);

            int length = list.Capacity;
            for (int i = 0; i < length; i++)
            {
                list.Add(i + 5);
            }

            Console.WriteLine("list -> element at index 1 = {0}", list.GetElement(1));
            Console.WriteLine();

            Console.WriteLine("list -> {0}", list);
            Console.WriteLine();

            list.InsertElementAtIndex(3, 7);
            list.InsertElementAtIndex(3, 7);
            list.InsertElementAtIndex(3, 7);
            list.InsertElementAtIndex(3, 7);
            list.InsertElementAtIndex(3, 7);
            list.InsertElementAtIndex(3, 7);
            list.InsertElementAtIndex(3, 7);

            Console.WriteLine("list -> {0}", list);
            Console.WriteLine();

            list.Add(7);

            Console.WriteLine("list -> {0}", list);
            Console.WriteLine();

            list.RemoveElementAtIndex(3);
            list.RemoveElementAtIndex(3);
            list.RemoveElementAtIndex(3);
            list.RemoveElementAtIndex(3);
            list.RemoveElementAtIndex(3);
            list.RemoveElementAtIndex(3);
            list.RemoveElementAtIndex(list.Count - 1);

            Console.WriteLine("list -> {0}", list);
            Console.WriteLine();

            Console.WriteLine("find index of value 4 -> {0}", list.FindByValue(4));
            Console.WriteLine("list -> {0}", list);
            Console.WriteLine();

            Console.WriteLine("list min-element -> {0}", list.Min());
            Console.WriteLine("list max-element -> {0}", list.Max());
            Console.WriteLine();

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

            Console.WriteLine("list -> {0}", list);
            Console.WriteLine();
        }
开发者ID:g-yonchev,项目名称:TelerikAcademy_2015_2016,代码行数:59,代码来源:GenericClassMain.cs

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

示例6: Main

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

            //Adding
            inputTest.Add(5);
            inputTest.Add(8);
            inputTest.Add(10);
            inputTest.Add(3);

            //Accessing
            int value= inputTest.AccessingByIndex(2);

            //Removing
            inputTest.Delete(2);

            //Inserting
            inputTest.Insert(1, 80);

            //Clearing
            //inputTest.Clear();

            //Finding element
            int index= inputTest.FindByValue(80);

            //ToString
            string output = inputTest.ToString();

            //Min value
            int minVal = inputTest.MinT();

            //Max value
            int maxVal = inputTest.MaxT();

            Console.WriteLine();
        }
开发者ID:zigzacvy,项目名称:Telerik_Akademy_Homework_CSharp,代码行数:36,代码来源:TestInput.cs


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