SmtpPermission::Intersect Method (IPermission^)

 

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

Namespace:   System.Net.Mail
Assembly:  System (in System.dll)

public:
virtual IPermission^ Intersect(
	IPermission^ target
) override

Parameters

target
Type: System.Security::IPermission^

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

Return Value

Type: System.Security::IPermission^

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.

Exception Condition
ArgumentException

target is not an SmtpPermission.

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.

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);
}

.NET Framework
Available since 2.0
Return to top
Show: