Export (0) Print
Expand All

WebPermission.Union Method

Returns the logical union between two instances of the WebPermission class.

[Visual Basic]
Overrides Public Function Union( _
   ByVal target As IPermission _
) As IPermission Implements IPermission.Union
[C#]
public override IPermission Union(
 IPermission target
);
[C++]
public: IPermission* Union(
 IPermission* target
);
[JScript]
public override function Union(
   target : IPermission
) : IPermission;

Parameters

target
The WebPermission to combine with the current WebPermission.

Return Value

A WebPermission that represents the union of the current instance and the target parameter. If either WebPermission is Unrestricted, the method returns a WebPermission that is Unrestricted. If the target is a null reference (Nothing in Visual Basic), returns a copy of current WebPermission.

Implements

IPermission.Union

Exceptions

Exception Type Condition
ArgumentException target is not a null reference (Nothing in Visual Basic) or of type WebPermission.

Remarks

Union returns a WebPermission that contains all the permissions in both target and the current instance.

Example

[Visual Basic, C#, C++] The following example takes the logical union of two WebPermission instances to create a third instance of WebPermission.

[Visual Basic] 
' Create another WebPermission that is the Union of previous two WebPermission 
' instances.
Dim myWebPermission3 As WebPermission = CType(myWebPermission1.Union(myWebPermission2), WebPermission)
Console.WriteLine(ControlChars.Cr + "Attributes and values of the WebPermission after the Union are : ")
' Display the attributes,values and children.
Console.WriteLine(myWebPermission3.ToXml().ToString())
   End Sub 'CreateUnion
    

[C#] 

    // Create another WebPermission that is the Union of previous two WebPermission 
    // instances.
    WebPermission myWebPermission3 =(WebPermission) myWebPermission1.Union(myWebPermission2);
    Console.WriteLine("\nAttributes and values of the WebPermission after the Union are : ");
    // Display the attributes,values and children.
    Console.WriteLine(myWebPermission3.ToXml().ToString());


[C++] 
// Create another WebPermission that is the Union of previous two WebPermission
// instances.
WebPermission* myWebPermission3 =dynamic_cast<WebPermission*> (myWebPermission1->Union(myWebPermission2));
Console::WriteLine(S"\nAttributes and values of the WebPermission after the Union are : ");
// Display the attributes, values and children.
Console::WriteLine(myWebPermission3->ToXml());

[JScript] No example is available for JScript. To view a Visual Basic, C#, or C++ example, click the Language Filter button Language Filter in the upper-left corner of the page.

Requirements

Platforms: Windows 98, Windows NT 4.0, Windows Millennium Edition, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows Server 2003 family, Common Language Infrastructure (CLI) Standard

See Also

WebPermission Class | WebPermission Members | System.Net Namespace | PermissionState

Show:
© 2014 Microsoft