HOW TO:測試是否相等 (C++/CLI)

在下列範例中,使用 Managed Extensions for 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)

請參閱

其他資源

Managed 型別 (C++/CLI)