#include "stdafx.h"
using namespace System;
bool ReallyEquals(array<int>^ a, array<int>^ b){
if (a->Length != b->Length)
return false;
for (int i = 0; i < a->Length; i++)
{
if (a[i] != b[i]) return false;
}
return true;
}
int main()
{
array<int>^ ai1 = gcnew array<int> { 1, 2 };
array<int>^ ai2 = gcnew array<int> { 1, 2 };
if ( ai1 == ai2 )
{
Console::WriteLine("The arrays are equal using the == operator.");
}
if (ai1->Equals(ai2) )
{
Console::WriteLine("The arrays are equal using the Equals method.");
}
if (ReallyEquals(ai1, ai2))
{
Console::WriteLine(
"The arrays are equal using element-by-element comparison.");
}
}
|