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


C# GenericList.Version方法代码示例

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


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

示例1: Main

 static void Main()
 {
     IGenericList<decimal> decimals = new GenericList<decimal>();
     decimals.Add(0.0001m);
     Console.WriteLine(decimals);
     Console.WriteLine(decimals.Version());
 }
开发者ID:naskoni,项目名称:SoftUni-OOP-November-2015,代码行数:7,代码来源:GenericListVersionExample.cs

示例2: Main

        static void Main()
        {
            GenericList<int> gl = new GenericList<int>();
            gl.Add(12);

            Console.WriteLine(gl.Version());
        }
开发者ID:krasi070,项目名称:OOP,代码行数:7,代码来源:MainProgram.cs

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

示例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(string[] args)
        {
            GenericList<string> list = new GenericList<string>();
            list.Add("Hello");

            // Will return GenericList class Version attribute at runtime using reflection
            // both GenericList<T> and VersionAttribute classes are in "03.GenericList" project
            Console.WriteLine(list.Version());
        }
开发者ID:mdamyanova,项目名称:Fundamental-Level,代码行数:9,代码来源:Program.cs

示例6: Main

        static void Main(string[] args)
        {
            GenericList<int> list = new GenericList<int>();
            for (int i = 0; i < 20; i++)
            {
                list.Add(i);
            }
            Console.WriteLine(list.Min());
            Console.WriteLine(list.Max());

            list.Version();
        }
开发者ID:noob2,项目名称:Fundamental-Level,代码行数:12,代码来源:Program.cs

示例7: Main

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

                //Console.WriteLine(list.Min());  // list is empty catched exception

                list.AddElement(1);
                list.AddElement(2);
                list.AddElement(3);
                list.AddElement(4);
                list.AddElement(5);
                list.AddElement(6);
                list.AddElement(7);
                list.AddElement(8);
                list.AddElement(9);
                list.AddElement(10);
                list.AddElement(11);
                list.AddElement(12);
                list.AddElement(13);
                list.AddElement(14);
                list.AddElement(15);
                list.AddElement(16);
                list.AddElement(17); // the list resizes here
                list.AddElement(18);
                list.Insert(-1, 0); // 1st param is the element, second param is the index

                Console.WriteLine("Min: " + list.Min());
                Console.WriteLine("Max: " + list.Max());
                Console.WriteLine("Index of -1: " + list.IndexOf(-1));
                Console.WriteLine("Trying to reach index of 100: " + list.IndexOf(100));
                Console.WriteLine("list.ToString():\n" + list);
                Console.WriteLine("List countains 20: " + list.Contains(20));
                Console.WriteLine("List contains 10: " + list.Contains(10));
                Console.WriteLine("clearing the list");
                Console.WriteLine(list.Version());
                list.Clear();
                Console.WriteLine("Trying to print the empty list:");
                Console.WriteLine(list);
            }
            catch (InvalidOperationException ioe)
            {

                Console.WriteLine(ioe.Message);
            }
        }
开发者ID:vangelov-i,项目名称:Fundamentals,代码行数:47,代码来源:Program.cs

示例8: Main

        public static void Main()
        {
            var list = new GenericList<int> { 2, 3, 4, 5, 6, 7, 8, 9, 10 };
            list.Version();

            Console.WriteLine(list.Count);
            list.Add(1);
            Console.WriteLine(list.Count);
            Console.WriteLine(list.Min());
            Console.WriteLine(list.Max());
            Console.WriteLine(list.Contains(11));
            Console.WriteLine(list.FindIndex(3));
            list.Insert(0, 5);
            Console.WriteLine(list);
            list.Remove(0);
            Console.WriteLine(list);
            list[0] = 18;
            Console.WriteLine(list);
            list.Clear();
            Console.WriteLine(list);
        }
开发者ID:LPetrova,项目名称:CSharpOPP,代码行数:21,代码来源:GenericListExec.cs

示例9: Main

        static void Main(string[] args)
        {
            var list = new GenericList<int>{ 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20 };

            list.Version();
            Console.WriteLine(list.Count);
            list.Add(1);
            Console.WriteLine(list.Count);
            Console.WriteLine(list.Min());
            Console.WriteLine(list.Max());
            Console.WriteLine(list.Contains(6));
            Console.WriteLine(list.FindIndex(17));
            list.Insert(21341, 12);
            Console.WriteLine(list);
            list.Remove(0);
            Console.WriteLine(list);
            list[2] = 23;
            Console.WriteLine(list);
            list.Clear();
            Console.WriteLine(list);
        }
开发者ID:ivailojordanov,项目名称:Fundamental-Level,代码行数:21,代码来源:GenericListMain.cs

示例10: Main

        static void Main()
        {
            GenericList<decimal> myList = new GenericList<decimal>();
            List<decimal> usedForFilling = new List<decimal> { 10.1m, 10.2m, 12.0m, 13.0m, 14.0m, 15.1m, 17.9m };
            for (int i = 0; i < usedForFilling.Count; i++)
            {
                myList.Add(usedForFilling[i]);
            }

            //myList.Insert(4.0m, 1);
            //Console.WriteLine("4.0 exists in the list: {0}", myList.Contains(4.0m));
            //Console.WriteLine("4.0 is on position {0}", myList.GetIndex(4.0m));
            //Console.WriteLine("List MAX is {0}", myList.Max());
            //Console.WriteLine("List MIN is {0}", myList.Min());
            //myList.RemoveAt(1);
            //Console.WriteLine("4.0 exists in the list: {0}", myList.Contains(4.0m));
            //Console.WriteLine("4.0 is on position {0}", myList.GetIndex(4.0m));

            myList.Version();
            //Console.WriteLine(myList.Version());
            myList.OrderByDescending(a => a).ToList().ForEach(a => Console.WriteLine(a));
        }
开发者ID:rextor92,项目名称:OOP-November2015,代码行数:22,代码来源:Test.cs

示例11: Main

        static void Main(string[] args)
        {
            //Problem 3 and 4 Solution

            var list = new GenericList<int> { 2, 3, 4, 5, 6, 7, 8, 9, 10 };
            list.Version();

            Console.WriteLine(list.Count);
            list.Add(1);
            Console.WriteLine(list.Count);
            Console.WriteLine(list.Min());
            Console.WriteLine(list.Max());
            Console.WriteLine(list.Contains(11));
            Console.WriteLine(list.FindIndex(3));
            list.Insert(0, 5);
            Console.WriteLine(list);
            list.Remove(0);
            Console.WriteLine(list);
            list[0] = 18;
            Console.WriteLine(list);
            list.Clear();
            Console.WriteLine(list);
        }
开发者ID:nikolay-dimitrov,项目名称:SoftUniHomeWorks,代码行数:23,代码来源:GenericListExec.cs.cs

示例12: Main

 static void Main()
 {
     var list = new GenericList<string>();
     Console.WriteLine(list.Version());
 }
开发者ID:HouseBreaker,项目名称:OOP,代码行数:5,代码来源:GenericListVersion.cs

示例13: Main

        static void Main(string[] args)
        {
            var list = new GenericList<int> { 12, 6, 9, 5, 45, 6, 6, 8, 95, 5 };
            Console.WriteLine("GenericList :");
            Console.WriteLine(list);
            list.Version();
            Console.WriteLine();

            Console.WriteLine("Adding an element");
            list.Add(1);
            Console.WriteLine(list);
            Console.WriteLine();

            Console.WriteLine("Accessing element by index");
            Console.WriteLine("The element at index {0} is {1}", 8, list[8]);
            Console.WriteLine();

            Console.WriteLine("The first index of {0} is {1}", 5, list.IndexOf(5));
            Console.WriteLine("The last index of {0} is {1}", 5, list.LastIndexOf(5));
            Console.WriteLine();

            Console.WriteLine("Removing element by index");
            list.RemoveAt(1);
            Console.WriteLine("Removing the element at index 1, result:");
            Console.WriteLine(list);
            Console.WriteLine();

            Console.WriteLine("Removing element by value");
            list.Remove(45);
            Console.WriteLine("Removing the element with value 45, result:");
            Console.WriteLine(list);
            Console.WriteLine();

            Console.WriteLine("Inserting element at given position");
            list.InsertAt(6, 14);
            Console.WriteLine("Inserted element with value 14 at index 6, result:");
            Console.WriteLine(list);
            Console.WriteLine();

            Console.WriteLine("Checking if the list contains an element with value 6");
            Console.WriteLine(list.Contains(6));
            Console.WriteLine();

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

            Console.WriteLine("List Count before clearing: {0}", list.Count);
            list.Clear();
            Console.WriteLine("List Count after clearing: {0}", list.Count);
            Console.WriteLine("Displaying the elements in the GenericList: {0}", list);
            Console.WriteLine();

            Console.WriteLine("Adding new elements to the GenericList");
            list.Add(6);
            list.Add(5);
            list.Add(89);
            list.Add(12);
            list.Add(5);
            list.Add(99);
            list.Add(65);
            list.Add(456);
            list.Add(44);
            list.Add(8768);
            list.Add(45488);
            list.Add(11);
            Console.WriteLine("GenericList: {0}", list);
            Console.WriteLine();

            System.Reflection.MemberInfo info = typeof(GenericList<>);
            foreach (object attribute in info.GetCustomAttributes(false))
            {
                Console.WriteLine(attribute);
            }
        }
开发者ID:sMustafov,项目名称:Object-Oriented-Programming,代码行数:75,代码来源:Program.cs

示例14: Main

        /// <summary>
        /// Defines the entry point of the application.
        /// </summary>
        public static void Main()
        {
            // so that you can see all the entire printed list of results
            Console.BufferHeight = 200;

            var list = new GenericList<int> { 2, 3, 4, 5, 6, 7, 8, 4, 10 };
            Console.WriteLine("Initial list");
            Console.WriteLine(list);
            list.Version();
            Console.WriteLine();

            // adding an element
            Console.WriteLine("Adding an element");
            Console.WriteLine("Adding element with value 1 to the end of the list:");
            list.Add(1);
            Console.WriteLine(list);
            Console.WriteLine();

            // accessing element by index
            Console.WriteLine("Accessing element by index");
            Console.WriteLine("The element at index {0} is {1}", 2, list[2]);
            Console.WriteLine();

            // finding element index by given value
            Console.WriteLine("Finding element index by given value");
            Console.WriteLine("The first index of {0} is {1}", 4, list.IndexOf(4));
            Console.WriteLine("The last index of {0} is {1}", 4, list.LastIndexOf(4));
            Console.WriteLine();

            // removing element by index
            Console.WriteLine("Removing element by index");
            list.RemoveAt(1);
            Console.WriteLine("Removing the element at index 1, result:");
            Console.WriteLine(list);
            Console.WriteLine();

            // removing element by value
            Console.WriteLine("Removing element by value");
            list.Remove(7);
            Console.WriteLine("Removing the element with value 7, result:");
            Console.WriteLine(list);
            Console.WriteLine();

            // inserting element at given position
            Console.WriteLine("Inserting element at given position");
            list.InsertAt(2, 8);
            Console.WriteLine("Inserted element with value 8 at index 2, result:");
            Console.WriteLine(list);
            Console.WriteLine();

            // checking if the list contains a value
            Console.WriteLine("Checking if the list contains a value");
            Console.WriteLine("Checking if the list contains an element with value 2");
            Console.WriteLine(list.Contains(2));
            Console.WriteLine("Checking if the list contains an element with value 11");
            Console.WriteLine(list.Contains(11));
            Console.WriteLine();

            // finding the minimal and maximal element in the GenericList<T>
            Console.WriteLine("Finding the minimal and maximal element in the GenericList<T>");
            Console.WriteLine("The minimal element in the GenericList is {0}", list.Min());
            Console.WriteLine("The maximal element in the GenericList is {0}", list.Max());
            Console.WriteLine();

            // clearing the list
            Console.WriteLine("Clearing the list");
            Console.WriteLine("GenericList count before clearing: {0}", list.Count);
            list.Clear();
            Console.WriteLine("GenericList count after clearing: {0}", list.Count);
            Console.WriteLine("Displaying the elements in the GenericList: {0}", list);
            Console.WriteLine();

            // adding new elements to the GenericList
            Console.WriteLine("Adding new elements to the GenericList");
            list.Add(6);
            list.Add(4);
            Console.WriteLine("GenericList: {0}", list);
            Console.WriteLine();

            System.Reflection.MemberInfo info = typeof(GenericList<>);
            foreach (object attribute in info.GetCustomAttributes(false))
            {
                Console.WriteLine(attribute);
            }
        }
开发者ID:KatyaMarincheva,项目名称:Object-Oriented-Programming-Course,代码行数:88,代码来源:Program.cs

示例15: TestGenericListMethods

        /// <summary>
        ///     Tests the generic list methods.
        /// </summary>
        public void TestGenericListMethods()
        {
            var list = new GenericList<int> { 2, 3, 4, 5, 6, 7, 8, 4, 10 };
            Console.WriteLine("Initial list");
            Console.WriteLine(list);
            list.Version();
            Console.WriteLine();

            // adding an element
            Console.WriteLine("Adding an element");
            Console.WriteLine("Adding element with value 1 to the end of the list:");
            list.Add(1);
            Console.WriteLine(list);
            Console.WriteLine();

            // accessing element by index
            Console.WriteLine("Accessing element by index");
            Console.WriteLine("The element at index {0} is {1}", 2, list[2]);
            Console.WriteLine();

            // finding element index by given value
            Console.WriteLine("Finding element index by given value");
            Console.WriteLine("The first index of {0} is {1}", 4, list.IndexOf(4));
            Console.WriteLine("The last index of {0} is {1}", 4, list.LastIndexOf(4));
            Console.WriteLine();

            // removing element by index
            Console.WriteLine("Removing element by index");
            list.RemoveAt(1);
            Console.WriteLine("Removing the element at index 1, result:");
            Console.WriteLine(list);
            Console.WriteLine();

            // removing element by value
            Console.WriteLine("Removing element by value");
            list.Remove(7);
            Console.WriteLine("Removing the element with value 7, result:");
            Console.WriteLine(list);
            Console.WriteLine();

            // inserting element at given position
            Console.WriteLine("Inserting element at given position");
            list.InsertAt(2, 8);
            Console.WriteLine("Inserted element with value 8 at index 2, result:");
            Console.WriteLine(list);
            Console.WriteLine();

            // checking if the list contains a value
            Console.WriteLine("Checking if the list contains a value");
            Console.WriteLine("Checking if the list contains an element with value 2");
            Console.WriteLine(list.Contains(2));
            Console.WriteLine("Checking if the list contains an element with value 11");
            Console.WriteLine(list.Contains(11));
            Console.WriteLine();

            // finding the minimal and maximal element in the GenericList<T>
            Console.WriteLine("Finding the minimal and maximal element in the GenericList<T>");
            Console.WriteLine("The minimal element in the GenericList is {0}", list.Min());
            Console.WriteLine("The maximal element in the GenericList is {0}", list.Max());
            Console.WriteLine();

            // clearing the list
            Console.WriteLine("Clearing the list");
            Console.WriteLine("GenericList count before clearing: {0}", list.Count);
            list.Clear();
            Console.WriteLine("GenericList count after clearing: {0}", list.Count);
            Console.WriteLine("Displaying the elements in the GenericList: {0}", list);
            Console.WriteLine();

            // adding new elements to the GenericList
            Console.WriteLine("Adding new elements to the GenericList");
            list.Add(6);
            list.Add(4);
            Console.WriteLine("GenericList: {0}", list);
            Console.WriteLine();
        }
开发者ID:KatyaMarincheva,项目名称:High-Quality-Code-Course,代码行数:79,代码来源:GenericListFunctionalityTest.cs


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