共用方式為


WebPermission.Union(IPermission) 方法

定義

傳回 WebPermission 類別的兩個執行個體間的邏輯等位。

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

參數

target
IPermission

WebPermission,要與目前的 WebPermission 比較。

傳回

WebPermission,表示目前執行個體和 target 參數間的聯集。 如果 WebPermissionUnrestricted,方法將傳回屬於 WebPermissionUnrestricted。 如果目標是 null,則方法會傳回目前 WebPermission 的複本。

例外狀況

目標不是 null 或屬於 WebPermission 型別。

範例

下列範例會採用兩 WebPermission 個實例的邏輯聯集,以建立 的第三個 實例 WebPermission

// 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() );

// 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());
   ' 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

備註

Union 會傳回 , WebPermission 其中包含和目前 實例中的所有 target 許可權。

適用於

另請參閱