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


C# System.Collections.ArrayList.Reverse方法代码示例

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


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

示例1: MostrarColeccionesNoGenerics


//.........这里部分代码省略.........
            for (int i = 0; i < cantidad; i++)
            {
                Console.WriteLine("Elemento {0} = {1}", i, cola.Dequeue());
            }

            Console.ReadLine();

            Console.WriteLine("Cantidad de elementos en la cola = {0}", cola.Count);
            Console.ReadLine();

            Console.Clear();
            Console.WriteLine("******************************");
            Console.WriteLine("******Listas Dinamicas********");
            Console.WriteLine("******************************");
            Console.ReadLine();

            System.Collections.ArrayList vec = new System.Collections.ArrayList();

            vec.Add(1);
            vec.Add(4);
            vec.Add(3);
            vec.Add(2);

            Console.WriteLine("Agrego elementos al ArrayList...");
            Console.WriteLine("Utilizo vec.Add()");
            Console.WriteLine("Orden de los elementos: 1 - 4 - 3 - 2");
            Console.ReadLine();

            Console.WriteLine("Muestro todos los elementos del ArrayList...");
            Console.WriteLine("Recorro con un foreach");
            Console.ReadLine();

            foreach (int elemento in vec)
            {
                Console.WriteLine(elemento);
            }

            Console.ReadLine();

            Console.WriteLine("Ordeno los elementos del ArrayList...");
            Console.WriteLine("Utilizo vec.Sort(). Recorro con un for");
            Console.ReadLine();

            vec.Sort();

            cantidad = vec.Count;

            for (int i = 0; i < cantidad; i++)
            {
                Console.WriteLine("Elemento {0} = {1}", i, vec[i]);
            }

            Console.ReadLine();

            Console.WriteLine("Ordeno los elementos del ArrayList...");
            Console.WriteLine("Utilizo vec.Reverse(). Recorro con un for");
            Console.ReadLine();

            vec.Reverse();

            cantidad = vec.Count;

            for (int i = 0; i < cantidad; i++)
            {
                Console.WriteLine("Elemento {0} = {1}", i, vec[i]);
            }

            Console.ReadLine();

            Console.Clear();
            Console.WriteLine("******************************");
            Console.WriteLine("*********HashTable************");
            Console.WriteLine("******************************");
            Console.ReadLine();

            System.Collections.Hashtable ht = new System.Collections.Hashtable();

            ht.Add(1, "valor 1");
            ht.Add(4, "valor 4");
            ht.Add(3, "valor 3");
            ht.Add(2, "valor 2");

            Console.WriteLine("Agrego elementos al HashTable...");
            Console.WriteLine("Utilizo vec.Add()");
            Console.WriteLine("Orden de los elementos: 1 - 4 - 3 - 2");
            Console.ReadLine();

            Console.WriteLine("Muestro todos los elementos del HashTable...");
            Console.WriteLine("Recorro con un for");
            Console.ReadLine();

            cantidad = ht.Count;

            for (int i = 1; i <= cantidad; i++)
            {
                Console.WriteLine("Elemento {0} = {1}", i, ht[i]);
            }

            Console.ReadLine();
        }
开发者ID:EugeniaPereyra,项目名称:EjemploDeColecciones,代码行数:101,代码来源:FuncionesColecciones.cs

示例2: RecordStack

        //Create a Set command for the identifier on top of the stack
        //NOTE: unlike GET, the last value on the SET stack is assumed to be the new value
        private void RecordStack(Type ExpectedDataType)
        {
            string total = "";
            //Add the dot notation
            System.Collections.ArrayList thiscommand = new System.Collections.ArrayList();
            foreach (string i in stack)
            {
                thiscommand.Add(i);
                thiscommand.Add(".");
            }

            //some string fixup
            thiscommand.Reverse();
            thiscommand.RemoveAt(thiscommand.Count - 2);
            string value = (string)thiscommand[thiscommand.Count - 1];
            thiscommand.RemoveAt(thiscommand.Count - 1);

            foreach (string i in thiscommand)
            {
                total += i;
            }
            //Total is not the name of the identifier
            //value is the value
            total = total.Substring(1);

            // add cmi. to all data model identifiers
            total = "cmi." + total;

            ScormSet ss = new ScormSet(total, value, ExpectedDataType);

            //set this on the serilization list
            //NOTE: we could just call the wrapper here directly
            wrapper.Set(ss);
        }
开发者ID:AntoineOctarina,项目名称:scorm4unity,代码行数:36,代码来源:ScormSerialization.cs


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