#include "stdafx.h"
using namespace System;
using namespace System::Collections;
ref class myReverserClass: public IComparer
{
public:
virtual int Compare(Object^ x, Object^ y) = IComparer::Compare
{
return (String::Compare((String^)y, (String^)x));
}
};
void main()
{
ArrayList ^alist = gcnew ArrayList(4);
alist->Add("One");
alist->Add("-");
array^ morenums = gcnew array {"Four", "Five"};
alist->AddRange(morenums);
IComparer^ myComparer = gcnew myReverserClass;
alist->Sort(myComparer);
int indx = alist->BinarySearch("Four", myComparer);
Console::WriteLine("Four found at index: {0}", indx.ToString());
}