Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections;
- namespace NOVEMBER_08A
- {
- class Program
- {
- static void Main(string[] args)
- {
- var p1 = new PlayingWithDataStructures();
- p1.Launch();
- Console.ReadLine();
- }
- }
- class PlayingWithDataStructures
- {
- public void Launch()
- {
- String[] dogs_names = new string[6] { "Rover", "Bigi", "Fifi", "Fido","Peanut", "Clarence" };
- ArrayList dogs = new ArrayList();
- foreach (string a in dogs_names)
- {
- string b = a;
- dogs.Add(b);
- }
- dogs.Add("Lulu");
- int whereIsPeanut = dogs.IndexOf("Peanut");
- Console.WriteLine("We found Peanut! He is at position {0}", whereIsPeanut);
- dogs.Sort();
- foreach (string a in dogs)
- {
- Console.WriteLine(a);
- }
- Console.WriteLine("-------------------------");
- Console.WriteLine("-------------------------");
- string secondElement = (string)dogs[1];
- Console.WriteLine("2nd element is : " + secondElement);
- dogs.Reverse();
- foreach (string a in dogs)
- {
- Console.WriteLine(a);
- }
- Console.WriteLine("-------------------------");
- dogs.Insert(3, "Poodles");
- foreach (string a in dogs)
- {
- Console.WriteLine(a);
- }
- Console.WriteLine("-------------------------");
- secondElement = (string)dogs[1];
- Console.WriteLine("2nd element is : " + secondElement);
- }
- }
- }
Add Comment
Please, Sign In to add comment