Was this page helpful?
Your feedback about this content is important. Let us know what you think.
Additional feedback?
1500 characters remaining
Intersect Method

DnsPermission::Intersect Method

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

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

virtual IPermission^ Intersect(
	IPermission^ target
) override


Type: System.Security::IPermission

The DnsPermission instance to intersect with the current instance.

Return Value

Type: System.Security::IPermission
A DnsPermission instance that represents the intersection of the current DnsPermission instance with the specified DnsPermission instance, or nullptr if the intersection is empty. If both the current instance and target are unrestricted, this method returns a new DnsPermission instance that is unrestricted; otherwise, it returns nullptr.




target is neither a DnsPermission nor nullptr.

The Intersect method returns a DnsPermission instance that allows the access defined by both the current DnsPermission instance and the specified DnsPermission instance. Any demand must pass both permissions to pass their intersection.

The following example creates a permission instance that is the intersection of the current permission instance and the specified permission instance.

   void useDns()
      // Create a DnsPermission instance.
      dnsPermission1 = gcnew DnsPermission( PermissionState::Unrestricted );
      dnsPermission2 = gcnew DnsPermission( PermissionState::None );
      // Check for permission.
      Console::WriteLine( "Attributes and Values of first DnsPermission instance :" );
      PrintKeysAndValues( dnsPermission1->ToXml()->Attributes );
      Console::WriteLine( "Attributes and Values of second DnsPermission instance :" );
      PrintKeysAndValues( dnsPermission2->ToXml()->Attributes );
      Console::WriteLine( "Union of both instances : " );
      Console::WriteLine( "Intersection of both instances : " );

   void PrintKeysAndValues( Hashtable^ myList )
      // Get the enumerator that can iterate through the hash tabble.
      IDictionaryEnumerator^ myEnumerator = myList->GetEnumerator();
      Console::WriteLine( "\t-KEY-\t-VALUE-" );
      while ( myEnumerator->MoveNext() )
         Console::WriteLine( "\t {0}:\t {1}", myEnumerator->Key, myEnumerator->Value );

   // Create a DnsPermission instance that is the intersection of current 
   // DnsPermission instance and the specified DnsPermission instance. 
   void MyIntersection()
      DnsPermission^ permission = dynamic_cast<DnsPermission^>(dnsPermission1->Intersect( dnsPermission2 ));
      // Print the attributes and the values of the intersection instance of 
      // DnsPermission.
      PrintKeysAndValues( permission->ToXml()->Attributes );

.NET Framework

Supported in: 4.6, 4.5, 4, 3.5, 3.0, 2.0, 1.1

.NET Framework Client Profile

Supported in: 4, 3.5 SP1
© 2015 Microsoft