#include "stdafx.h"
using namespace System;
int main()
{
array<int>^ array1 = gcnew array<int>(10){ 2, 7, 9, 6, 4, 1, 9, 5, 0, 10 };
Array::Sort(array1);
for each (int i in array1)
{
Console::Write("{0} ", i);
}
// Search for one of the values
int index = Array::BinarySearch( array1, 115);
if (index >= 0 )
Console::WriteLine( "Found {0} at position {1}.", array1[index], index );
else
Console::WriteLine(" Not Found. ");
}
|