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


C# GenericList.GetElement方法代码示例

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


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

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

示例2: Main

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

            //Console.WriteLine(a.Capacity);
            a.AddElement(6);
            a.AddElement(7);
            a.AddElement(8);
            //Console.WriteLine(a.Count);

            //Console.WriteLine(a.GetElement(2));

            a.RemoveElement(2);

            for (int i = 0; i < a.Count; i++)
            {
                Console.WriteLine(a.GetElement(i));
            }

            Console.WriteLine();
            a.InsertElement(24, 5);

            for (int i = 0; i < a.Count; i++)
            {
                Console.WriteLine(a.GetElement(i));
            }
            Console.WriteLine();

            //a.Clear();
            //for (int i = 0; i < a.Count; i++)
            //{
            //    Console.WriteLine(a.GetElement(i));
            //}

            Console.WriteLine();

            Console.WriteLine(a.GetIndexOf(7));
        }
开发者ID:DimitarGaydardzhiev,项目名称:TelerikAcademy,代码行数:38,代码来源:MainProgram.cs

示例3: Main

        static void Main(string[] args) {
            IGenericList<string> stringList = new GenericList<string>();
            stringList.Add("Hello");
            stringList.Add("World");
            stringList.Add("!");
            Console.WriteLine(stringList.Count); // 3
            Console.WriteLine(stringList.Contains("Hello")); // true
            Console.WriteLine(stringList.IndexOf("Hello")); // 0
            Console.WriteLine(stringList.GetElement(1)); // World
            IGenericList<double> doubleList = new GenericList<double>();
            doubleList.Add(0.2);
            doubleList.Add(0.7);

            Console.ReadLine();
        }
开发者ID:Marin39,项目名称:1.zadaca,代码行数:15,代码来源:Program.cs

示例4: Main

        static void Main(string[] args)
        {
            IntegerList listOfIntegers = new IntegerList(1);

            listOfIntegers.Add(1);
            listOfIntegers.Add(2);
            listOfIntegers.Add(3);
            listOfIntegers.Add(4);
            listOfIntegers.Add(5); // lista je [1,2,3,4,5]
            printList(listOfIntegers);

            // Mičemo prvi element liste.
            listOfIntegers.RemoveAt(0); // Lista je [2,3,4,5]
            printList(listOfIntegers);

            // Mičemo element liste čija je vrijednost "5".
            listOfIntegers.Remove(5); // Lista je [2,3,4]
            printList(listOfIntegers);

            Console.WriteLine(listOfIntegers.Count); // 3
            Console.WriteLine(listOfIntegers.Remove(100)); // false, nemamo element u vrijednosti 100
            Console.WriteLine(listOfIntegers.RemoveAt(5)); // false, nemamo ništa na poziciji 5

            // Brišemo sav sadržaj kolekcije
            listOfIntegers.Clear();
            Console.WriteLine(listOfIntegers.Count);

            IGenericList<string> stringList = new GenericList<string>();
            stringList.Add("Hello");
            stringList.Add("World");
            stringList.Add("!");

            Console.WriteLine(stringList.Count); // 3 
            Console.WriteLine(stringList.Contains("Hello")); // true 
            Console.WriteLine(stringList.IndexOf("Hello")); // 0 
            Console.WriteLine(stringList.GetElement(1)); // World 

            IGenericList<double> doubleList = new GenericList<double>();
            doubleList.Add(0.2);
            doubleList.Add(0.7);

            foreach (string str in stringList)
            {
                Console.WriteLine(str);
            }

            Console.ReadLine();
        }
开发者ID:dkrivosic,项目名称:1.Zadaca,代码行数:48,代码来源:Program.cs

示例5: Main

        static void Main(string[] args)
        {
            IGenericList<string> stringList = new GenericList<string>();
            stringList.Add("Hello");
            stringList.Add("World");
            stringList.Add("!");
            Console.WriteLine("String List: " + stringList.ToString());

            Console.WriteLine(stringList.Count); // 3 
            Console.WriteLine(stringList.Contains("Hello")); // true 
            Console.WriteLine(stringList.IndexOf("Hello")); // 0 
            Console.WriteLine(stringList.GetElement(1) + "\n"); // World 
            
            foreach (string value in stringList)
            {
                Console.WriteLine(value);
            }

            Console.ReadLine();
        }
开发者ID:v-silverfin,项目名称:1.zadaca,代码行数:20,代码来源:ExampleZ4.cs

示例6: Main

 public static int Main()
 {
     GenericList<int> list = new GenericList<int>(20);
     for (int i = 0; i <= 45; i++)
     {
         list.AddElement(i + 5);
     }
     list.RemoveElement(5);
     Console.Write("Elements: ");
     for (int i = 0; i <= list.Size() - 1; i++)
     {
         Console.Write(list.GetElement((uint)i));
         if (i < list.Size() - 1)
         {
             Console.Write(",");
         }
     }
     Console.WriteLine("\n{0}",list.FindElementByVal(40));
     Console.WriteLine(list.Min());
     Console.WriteLine(list.Max());
     Console.WriteLine(list.ToString());
     return 0;
 }
开发者ID:K-Pavlov,项目名称:Telerik,代码行数:23,代码来源:Test.cs

示例7: Main

        static void Main()
        {
            //Problem 1-4 tests
            Point3D point = new Point3D(2, 3, 4);

            Console.WriteLine(point.ToString());

            Point3D staticPoint = Point3D.StartPoint;
            Console.WriteLine(staticPoint.ToString());

            Point3D a = new Point3D(0, 1, 2);
            Point3D b = new Point3D(2, 3, 4);

            Path g = new Path();
            g.AddPoint(a);
            g.AddPoint(b);

            PathStorage.SavePath(g,"bla");

            //Problem 5-8 tests

            GenericList<int> myList = new GenericList<int>(3);

            myList.AddElement(1);
            myList.AddElement(2);
            myList.AddElement(3);

            Console.WriteLine();
            Console.WriteLine("add elements:");

            for (int i = 0; i < myList.Elements.Length; i++)
            {
                Console.WriteLine(myList.Elements[i]);
            }
            Console.WriteLine();

            Console.WriteLine();

            myList.RemoveElement(2);

            for (int i = 0; i < myList.Elements.Length; i++)
            {
                Console.WriteLine(myList.Elements[i]);
            }

            Console.WriteLine();

            myList.InsertElement(555, 0);

            for (int i = 0; i < myList.Elements.Length; i++)
            {
                Console.WriteLine(myList.Elements[i]);
            }

            Console.WriteLine();

            for (int i = 0; i < myList.Elements.Length; i++)
            {
                Console.WriteLine(myList.Elements[i]);
            }

            Console.WriteLine();

            Console.WriteLine(myList.FindElement(555));

            Console.WriteLine(myList.ToString());

            Console.WriteLine();

            Console.WriteLine(myList.GetElement(1));
        }
开发者ID:ztodorova,项目名称:Telerik-Academy,代码行数:71,代码来源:MainMethod.cs

示例8: GettingElementTest

 public void GettingElementTest()
 {
     GenericList<string> generic = new GenericList<string>(2);
     generic.AddElement("Pesho");
     generic.AddElement("Gosho");
     generic.AddElement("Kircho");
     string element = generic.GetElement(0);
     Assert.AreEqual("Pesho", element);
 }
开发者ID:abaditsegay,项目名称:SVN,代码行数:9,代码来源:UnitTest1.cs


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