共用方式為


auto_handle::swap

交換物件與另一個auto_handle。

void swap(
   auto_handle<_element_type> % _right
);

參數

  • _right
    auto_handle用來交換物件。

範例

// msl_auto_handle_swap.cpp
// compile with: /clr
#include <msclr\auto_handle.h>

using namespace System;
using namespace msclr;

int main() {
   auto_handle<String> s1 = "string one";
   auto_handle<String> s2 = "string two";

   Console::WriteLine( "s1 = '{0}', s2 = '{1}'",
      s1->ToString(), s2->ToString() );
   s1.swap( s2 );
   Console::WriteLine( "s1 = '{0}', s2 = '{1}'",
      s1->ToString(), s2->ToString() );
}
  

需求

標頭檔 <msclr\auto_handle.h>

Namespace msclr

請參閱

參考

交換函式 (auto_handle)

其他資源

auto_handle Members