Array.Reverse : Array « System « C# / C Sharp by API






Array.Reverse

  
/*
Learning C# 
by Jesse Liberty

Publisher: O'Reilly 
ISBN: 0596003765
*/
 using System;

 namespace ReverseAndSort
 {
    public class TesterReverseAndSort
    {

        public static void DisplayArray(object[] theArray)
        {

            foreach (object obj in theArray)
            {
                Console.WriteLine("Value: {0}", obj);
            }
            Console.WriteLine("\n");
        }

       public void Run()
       {
           String[] myArray =
             {
                 "Who", "is", "John", "Galt"
             };

           Console.WriteLine("Display myArray...");
           DisplayArray(myArray);

           Console.WriteLine("Reverse and display myArray...");
           Array.Reverse(myArray);
           DisplayArray(myArray);

           String[] myOtherArray =
             {
                 "We", "Hold", "These", "Truths",
                 "To", "Be", "Self", "Evident",
           };

           Console.WriteLine("Display myOtherArray...");
           DisplayArray(myOtherArray);

           Console.WriteLine("Sort and display myOtherArray...");
           Array.Sort(myOtherArray);
           DisplayArray(myOtherArray);
       }

       [STAThread]
       static void Main()
       {
          TesterReverseAndSort t = new TesterReverseAndSort();
          t.Run();
       }
    }
 }

   
    
  








Related examples in the same category

1.Array.AsReadOnly
2.Array.BinarySearch
3.Array.Clone
4.Array.ConvertAll
5.Array.Copy
6.Array.CopyTo
7.Array.Count
8.Array.CreateInstance
9.Array.Exists
10.Array.Find
11.Array.FindAll
12.Array.ForEach
13.Array.GetEnumerator()
14.Array.GetLength()
15.Array.GetLowerbound
16.Array.GetUpperBound
17.Array.IndexOf
18.Array.LastIndexOf
19.Array.Length
20.Array.Rank
21.Array.Resize
22.Array.Reverse(nums, 1, 3)
23.Array.Sort
24.Array.Sort(names, Comparer.DefaultInvariant)
25.Array.SyncRoot