Freigeben über


How to: Test for Equality (C++/CLI)

 

The new home for Visual Studio documentation is Visual Studio 2017 Documentation on docs.microsoft.com.

The latest version of this topic can be found at How to: Test for Equality (C++/CLI).

In the following sample, a test for equality that uses Managed Extensions for C++ is based on what the handles refer to.

Example

// mcppv2_equality_test.cpp  
// compile with: /clr /LD  
using namespace System;  
  
bool Test1() {  
   String ^ str1 = "test";  
   String ^ str2 = "test";  
   return (str1 == str2);  
}  

The IL for this program shows that the return value is implemented by using a call to op_Equality.

IL_0012:  call       bool [mscorlib]System.String::op_Equality(string,  
                                                               string)  

See Also

Managed Types (C++/CLI)