在下面的示例中,将根据处理程序所指对象使用 C++ 托管扩展进行相等测试。
示例
// mcppv2_equality_test.cpp
// compile with: /clr /LD
using namespace System;
bool Test1() {
   String ^ str1 = "test";
   String ^ str2 = "test";
   return (str1 == str2);
}
此程序的 IL 演示通过调用 op_Equality 实现返回值。
  IL_0012:  call       bool [mscorlib]System.String::op_Equality(string,
                                                                 string)