本文整理汇总了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();
}
示例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);
}