DnsPermission.IsSubsetOf Method (IPermission)


The .NET API Reference documentation has a new home. Visit the .NET API Browser on docs.microsoft.com to see the new experience.

Determines whether the current permission instance is a subset of the specified permission instance.

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

Public Overrides Function IsSubsetOf (
	target As IPermission
) As Boolean


Type: System.Security.IPermission

The second DnsPermission instance to be tested for the subset relationship.

Return Value

Type: System.Boolean

false if the current instance is unrestricted and target is either null or unrestricted; otherwise, true.

Exception Condition

target is neither a DnsPermission nor null.

The current DnsPermission instance is a subset of the specified DnsPermission instance if the current DnsPermission instance specifies a set of operations that is wholly contained by the specified DnsPermission instance.

If the IsSubsetOf method returns true, the current DnsPermission instance allows no more access to DNS servers than does the specified DnsPermission instance.

The following example uses the IsSubsetOf method to determine whether the current permission instance is a subset of the specified permission instance.

Public Sub useDns()
    ' Create a DnsPermission instance.
    permission = New DnsPermission(PermissionState.Unrestricted)
    Dim dnsPermission1 As New DnsPermission(PermissionState.None)
    ' Check  for permission.
    ' Print the attributes and values.
    Console.WriteLine("Attributes and Values of 'DnsPermission' instance :")
    Console.WriteLine("Attributes and Values of specified 'DnsPermission' instance :")
End Sub 'useDns

Private Sub Subset(Permission1 As DnsPermission)
    If permission.IsSubsetOf(Permission1) Then
        Console.WriteLine("Current 'DnsPermission' instance is a subset of specified 'DnsPermission' instance.")
        Console.WriteLine("Current 'DnsPermission' instance is not a subset of specified 'DnsPermission' instance.")
    End If
End Sub 'Subset

Private Sub PrintKeysAndValues(myList As Hashtable)
    ' Get the enumerator that can iterate through the hash table.
    Dim myEnumerator As IDictionaryEnumerator = myList.GetEnumerator()
    Console.WriteLine(ControlChars.Tab + "-KEY-" + ControlChars.Tab + "-VALUE-")
    While myEnumerator.MoveNext()
        Console.WriteLine(ControlChars.Tab + "{0}:" + ControlChars.Tab + "{1}", myEnumerator.Key, myEnumerator.Value)
    End While
End Sub 'PrintKeysAndValues

.NET Framework
Available since 1.1
Return to top