共用方式為


DataProtectionPermission.Copy 方法

定義

建立並傳回目前權限的相同複本。

public:
 override System::Security::IPermission ^ Copy();
public override System.Security.IPermission Copy ();
override this.Copy : unit -> System.Security.IPermission
Public Overrides Function Copy () As IPermission

傳回

目前權限的複本。

範例

下列程式碼範例顯示 方法的使用 Copy 方式。 此程式碼範例是針對 類別提供的較大範例的 DataProtectionPermission 一部分。

注意

程式碼範例旨在顯示 方法的行為,而不是示範其用法。 一般而言,安全性基礎結構會使用許可權類別的方法;它們通常不會用於應用程式。

Console::WriteLine( "Copying the second permission to the fourth "
"permission." );
sp4 = dynamic_cast<DataProtectionPermission^>(sp2->Copy());
rc = sp4->Equals( sp2 );
Console::WriteLine( "Is the fourth permission equal to the second "
"permission? {0}", (rc ? (String^)"Yes" : "No") );
Console.WriteLine("Copying the second permission to the fourth " +
    "permission.");
sp4 = (DataProtectionPermission)sp2.Copy();
rc = sp4.Equals(sp2);
Console.WriteLine("Is the fourth permission equal to the second " +
    "permission? " + (rc ? "Yes" : "No"));
Console.WriteLine("Copying the second permission to the fourth " + "permission.")
sp4 = CType(sp2.Copy(), DataProtectionPermission)
rc = sp4.Equals(sp2)
Console.WriteLine("Is the fourth permission equal to the second " + "permission? " + IIf(rc, "Yes", "No")) 'TODO: For performance reasons this should be changed to nested IF statements

備註

許可權的複本代表與原始許可權相同的資源存取權。

適用於