WebPermission.Copy 方法

定义

创建 WebPermission 的副本。

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

返回

WebPermission 类的新实例,该实例与原始对象具有相同的值。

示例

以下示例演示如何使用 Copy创建 的第WebPermission二个实例。 第二个实例与第一个实例相同。

// Create another WebPermission instance that is the copy of the above WebPermission instance.
WebPermission^ myWebPermission2 = (WebPermission^)(myWebPermission1->Copy());

// Check whether all callers higher in the call stack have been granted the permissionor not.
myWebPermission2->Demand();
 // Create another WebPermission instance that is the copy of the above WebPermission instance.
  WebPermission myWebPermission2 = (WebPermission) myWebPermission1.Copy();

 // Check whether all callers higher in the call stack have been granted the permissionor not.
 myWebPermission2.Demand();
' Create another WebPermission instance that is the copy of the above WebPermission instance.
Dim myWebPermission2 As WebPermission = CType(myWebPermission1.Copy(), WebPermission)

' Check whether all callers higher in the call stack have been granted the permissionor not.
myWebPermission2.Demand()

注解

IPermission此方法返回的 表示对资源的访问权限与原始 WebPermission相同。 此方法替代 Copy 并实现以支持 IPermission 接口。

适用于