共用方式為


auto_gcroot::operator!

運算子用於 auto_gcroot 條件運算式。

bool operator!() const;

傳回值

true ,如果包裝的物件無效;否則為 false 。

範例

// msl_auto_gcroot_operator_not.cpp
// compile with: /clr
#include <msclr\auto_gcroot.h>

using namespace System;
using namespace msclr;

int main() {
   auto_gcroot<String^> s;
   if ( s ) Console::WriteLine( "s is valid" );
   if ( !s ) Console::WriteLine( "s is invalid" );
   s = "something";
   if ( s ) Console::WriteLine( "now s is valid" );
   if ( !s ) Console::WriteLine( "now s is invalid" );
   s.reset();
   if ( s ) Console::WriteLine( "now s is valid" );
   if ( !s ) Console::WriteLine( "now s is invalid" );
}
  

需求

標頭檔 <msclr \ auto_gcroot.h>

命名空間 msclr

請參閱

參考

auto_gcroot::operator bool

其他資源

auto_gcroot 成員