DataProtectionPermission.Intersect(IPermission) 方法

定义

创建并返回一个权限,该权限是当前权限与指定权限的交集。

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

参数

target
IPermission

要与当前权限相交的权限。 它必须与当前权限属于同一类型。

返回

表示当前权限和指定权限的交集的一个新权限。 如果交集为空,则此新权限为 null

例外

target 不是 null,并且未指定同一类型的权限为当前权限。

示例

下面的代码示例演示如何使用 Intersect 方法。 此代码示例是为 DataProtectionPermission 类提供的一个更大示例的一部分。

Console::WriteLine( "Creating the intersection of the second and "
"first permissions." );
sp4 = dynamic_cast<DataProtectionPermission^>(sp2->Intersect( sp1 ));
Console::WriteLine( "The value of the Flags property is: {0}", sp4->Flags );
Console.WriteLine("Creating the intersection of the second and " +
    "first permissions.");
sp4 = (DataProtectionPermission)sp2.Intersect(sp1);
Console.WriteLine("The value of the Flags property is: " +
    sp4.Flags.ToString());
Console.WriteLine("Creating the intersection of the second and " + "first permissions.")
sp4 = CType(sp2.Intersect(sp1), DataProtectionPermission)
Console.WriteLine("The value of the Flags property is: " + sp4.Flags.ToString())

注解

两个权限的交集是一个权限,用于描述它们共同描述的操作集。 只有传递这两个单独权限的要求才会传递交集。

适用于