daily pastebin goal
11%
SHARE
TWEET

Untitled

a guest Nov 8th, 2018 85 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. using System;
  2. using System.Collections;
  3.  
  4.  
  5. namespace NOVEMBER_08A
  6. {
  7.     class Program
  8.     {
  9.         static void Main(string[] args)
  10.         {
  11.             var p1 = new PlayingWithDataStructures();
  12.             p1.Launch();
  13.             Console.ReadLine();
  14.         }
  15.     }
  16.  
  17.     class PlayingWithDataStructures
  18.     {
  19.  
  20.         public void Launch()
  21.         {
  22.             String[] dogs_names = new string[6] { "Rover", "Bigi", "Fifi", "Fido","Peanut",  "Clarence" };
  23.             ArrayList dogs = new ArrayList();
  24.            
  25.             foreach (string a in dogs_names)
  26.             {
  27.                 string b = a;
  28.                 dogs.Add(b);
  29.             }
  30.             dogs.Add("Lulu");
  31.             int whereIsPeanut = dogs.IndexOf("Peanut");
  32.             Console.WriteLine("We found Peanut! He is at position {0}", whereIsPeanut);
  33.             dogs.Sort();
  34.             foreach (string a in dogs)
  35.             {
  36.                 Console.WriteLine(a);
  37.             }
  38.             Console.WriteLine("-------------------------");
  39.  
  40.             Console.WriteLine("-------------------------");
  41.             string secondElement = (string)dogs[1];
  42.             Console.WriteLine("2nd element is : " + secondElement);
  43.             dogs.Reverse();
  44.             foreach (string a in dogs)
  45.             {
  46.                 Console.WriteLine(a);
  47.             }
  48.             Console.WriteLine("-------------------------");
  49.             dogs.Insert(3, "Poodles");
  50.             foreach (string a in dogs)
  51.             {
  52.                 Console.WriteLine(a);
  53.             }
  54.             Console.WriteLine("-------------------------");
  55.             secondElement = (string)dogs[1];
  56.             Console.WriteLine("2nd element is : " + secondElement);
  57.         }
  58.  
  59.     }
  60. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top