using System;using System.Collections;namespace ARRAYLIST{    class Program    {        public static void Main(string[] a...
using System;using System.Collections;namespace stack{  class Program  {     public static void Main(string[] args)     { ...
using System;    using System.Collections.Generic;   namespace queue   {   class Program   {       static void Main()     ...
Colecções C#
Colecções C#
Colecções C#
Colecções C#
Colecções C#
Colecções C#
Upcoming SlideShare
Loading in...5
×

Colecções C#

284

Published on

0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total Views
284
On Slideshare
0
From Embeds
0
Number of Embeds
0
Actions
Shares
0
Downloads
2
Comments
0
Likes
0
Embeds 0
No embeds

No notes for slide

Colecções C#

  1. 1. 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); } }}
  2. 2. 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); } }}
  3. 3. 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 Queues 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); } } }
  1. A particular slide catching your eye?

    Clipping is a handy way to collect important slides you want to go back to later.

×