Your SlideShare is downloading. ×
Colecções C#
Upcoming SlideShare
Loading in...5
×

Thanks for flagging this SlideShare!

Oops! An error has occurred.

×

Saving this for later?

Get the SlideShare app to save on your phone or tablet. Read anywhere, anytime - even offline.

Text the download link to your phone

Standard text messaging rates apply

Colecções C#

262
views

Published on


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

  • Be the first to like this

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

Report content
Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
No notes for slide

Transcript

  • 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. 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. 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); } } }