public IsSubsetOf ( |
||
target | ||
return | bool |
// Create two permission sets PermissionSet firstSet = new PermissionSet(PermissionState.None); firstSet.AddPermission(new FileIOPermission(FileIOPermissionAccess.Read, "C:\\Temp")); firstSet.AddPermission(new SecurityPermission(SecurityPermissionFlag.Execution)); PermissionSet secondSet = new PermissionSet(PermissionState.None); secondSet.AddPermission(new FileIOPermission(FileIOPermissionAccess.Write, "C:\\Temp")); // Check if firstSet is a subset of secondSet if (firstSet.IsSubsetOf(secondSet)) { Console.WriteLine("firstSet is a subset of secondSet."); } else { Console.WriteLine("firstSet is not a subset of secondSet."); }
// Create two permission sets PermissionSet firstSet = new PermissionSet(PermissionState.None); firstSet.AddPermission(new FileIOPermission(FileIOPermissionAccess.Write, "C:\\Temp")); firstSet.AddPermission(new SecurityPermission(SecurityPermissionFlag.Execution)); PermissionSet secondSet = new PermissionSet(PermissionState.None); secondSet.AddPermission(new FileIOPermission(FileIOPermissionAccess.Write, "C:\\Temp")); secondSet.AddPermission(new SecurityPermission(SecurityPermissionFlag.Execution)); // Check if firstSet is a subset of secondSet if (firstSet.IsSubsetOf(secondSet)) { Console.WriteLine("firstSet is a subset of secondSet."); } else { Console.WriteLine("firstSet is not a subset of secondSet."); }In this example, we create two permission sets again: `firstSet` and `secondSet`. However, this time `secondSet` contains all the permissions in `firstSet`, so `firstSet` is indeed a subset of `secondSet`, and the result should be true. The `IsSubsetOf` method is part of the `System.Security.Permissions` namespace, which is included in the `mscorlib` assembly.