編集

次の方法で共有


SmtpPermission.Intersect(IPermission) Method

Definition

Creates and returns a permission that is the intersection of the current permission and the specified permission.

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

Parameters

target
IPermission

An IPermission to intersect with the current permission. It must be of the same type as the current permission.

Returns

An SmtpPermission that represents the intersection of the current permission and the specified permission. Returns null if the intersection is empty or target is null.

Exceptions

target is not an SmtpPermission.

Examples

The following code example creates a permission object that is the intersection of an existing permission with an object that grants full access to SMTP servers.

static SmtpPermission^ IntersectionWithFull(
    SmtpPermission^ permission)
{
    SmtpPermission^ allAccess = 
        gcnew SmtpPermission(PermissionState::Unrestricted);
    return (SmtpPermission^) permission->Intersect(allAccess);
}
public static SmtpPermission IntersectionWithFull(SmtpPermission permission)
{
    SmtpPermission allAccess = new
        SmtpPermission(System.Security.Permissions.PermissionState.Unrestricted);
    return (SmtpPermission) permission.Intersect(allAccess);
}

Remarks

The intersection of two permissions is a permission that describes the state they describe in common. Only a demand that passes both original permissions will pass the intersection.

Applies to