Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Colecções C#
1.
2.
3.
4. using System;
using System.Collections;
namespace ARRAYLIST
{
class Program
{
public static void Main(string[] args)
{
//
// Cria um ArrayList e adiciona três
// elementos.
//
ArrayList i = new ArrayList();
i.Add("One");
i.Add("Two");
i.Add("Three");
Console.WriteLine(i.Count);
Console.Write(". . . ");
Console.ReadKey(true);
}
}
}
5.
6. using System;
using System.Collections;
namespace stack
{
class Program
{
public static void Main(string[] args)
{
Stack vegStack = new Stack();
vegStack.Push("Raddish");
vegStack.Push("Cabbage");
vegStack.Push("Carrot");
vegStack.Push("Brinjal");
vegStack.Push("Onion");
Console.WriteLine("Contents of Vegetable Stack...");
foreach(string veg in vegStack)
{
Console.WriteLine(veg);
}
while(vegStack.Count > 0)
{
string veg = (string) vegStack.Pop();
Console.WriteLine("Popping {0}", veg );
}
Console.Write("Press any key . . . ");
Console.ReadKey(true);
}
}
}
7.
8. using System;
using System.Collections.Generic;
namespace queue
{
class Program
{
static void Main()
{
// New Queue of integers.
Queue<int> queue = new Queue<int>();
queue.Enqueue(5);
queue.Enqueue(10);
queue.Enqueue(15);
queue.Enqueue(20);
// Create new array with Length equal to Queue's element count.
int[] array = new int[queue.Count];
// Copy the Queue to the int array.
queue.CopyTo(array, 0);
// Loop through and display int[] in order.
Console.WriteLine("Array:");
for (int i = 0; i < array.Length; i++)
{
Console.WriteLine(array[i]);
}
// Loop through int array in reverse order.
Console.WriteLine("Array reverse order:");
for (int i = array.Length - 1; i >= 0; i--)
{
Console.WriteLine(array[i]);
}
Console.ReadKey(true);
}
}
}