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 Members