public static void Main()
Array myIntArray = Array.CreateInstance(typeof(Int32), 5);
myIntArray.SetValue(8, 0);
myIntArray.SetValue(2, 1);
myIntArray.SetValue(6, 2);
myIntArray.SetValue(3, 3);
myIntArray.SetValue(7, 4);
Console.WriteLine( "The Int32 array contains the following:" );
int myIndex=Array.BinarySearch(myIntArray, myObject);
Console.WriteLine("The object to search for ({0}) is not found. The next larger object is at index {1}.", myObject, ~myIndex );
Console.WriteLine("The object to search for ({0}) is at index {1}.", myObject, myIndex );
public static void PrintValues(Array myArr)
int cols = myArr.GetLength(myArr.Rank - 1);
foreach (object o in myArr)
Console.Write( "\t{0}", o);