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


C# GenericList.RemoveAll方法代码示例

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


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

示例1: Main

    static void Main()
    {
        var list = new GenericList<int>();
        list.Add(1);
        list.Add(2);
        list.Add(3);
        list.Add(4);
        list.Add(3);
        Console.WriteLine(list);

        list[4] = 5;
        Console.WriteLine(list);

        list.Add(-5);
        Console.WriteLine(list);

        Console.WriteLine("list[2] = " + list[2]);
        Console.WriteLine();

        list.RemoveByIndex(list.Count - 1);
        Console.WriteLine(list);
        Console.WriteLine();

        list.Insert(list.Count, 0);
        Console.WriteLine(list);
        Console.WriteLine();

        Console.WriteLine(list.GetIndexByValue(5));
        Console.WriteLine(list.IsContain(5));

        Console.WriteLine("Max = " + list.Max());
        Console.WriteLine("Min = " + list.Min());
        Console.WriteLine();

        list.RemoveAll();
        Console.WriteLine("Empty list" + list);

        Type type = typeof(GenericList<>);
        object[] allAttributes = type.GetCustomAttributes(typeof(VersionAttribute), false);
        Console.WriteLine("GenericsList's version is {0}", ((VersionAttribute)allAttributes[0]).Version);



    }
开发者ID:ScreeM92,项目名称:Software-University,代码行数:44,代码来源:TestGenericList.cs

示例2: Main

        static void Main(string[] args)
        {
            var list = new GenericList<int>();
            list.Add(1);
            list.Add(2);
            list.Add(3);
            list.Add(4);
            list.Add(5);

            list[4] = 19;
            Console.WriteLine(list);

            list.Add(-5);
            Console.WriteLine(list);

            Console.WriteLine("list[4] = " + list[4]);

            list.RemoveByIndex(list.Count - 1);
            Console.WriteLine(list);
            Console.WriteLine("{0}",new string('-',60));

            list.Insert(list.Count, 5);
            Console.WriteLine(list);
            Console.WriteLine("{0}", new string('-', 60));

            Console.WriteLine(list.GetIndexByValue(5));
            Console.WriteLine(list.IsContain(8));
            Console.WriteLine("{0}", new string('-', 60));

            Console.WriteLine("Highest = " + list.Max());
            Console.WriteLine("Lowest = " + list.Min());
            Console.WriteLine("{0}", new string('-', 60));

            list.RemoveAll();
            Console.WriteLine("After the List was Deleted = " + list);
            Console.WriteLine("{0}", new string('-', 60));

            Type type = typeof(GenericList<>);
            object[] allAttributes = type.GetCustomAttributes(typeof(VersionAttribute), true);
        }
开发者ID:AlexanderDimitrov,项目名称:OOP,代码行数:40,代码来源:Test.cs


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