Searches for a matching access control with which the new rule can be merged. If none are found, adds the new rule.
The RegistrySecurity.AddAccessRule(RegistryAccessRule) method searches for rules with the same user or group and the same System.Security.AccessControl.AccessControlType as rule. If none are found, rule is added. If a matching rule is found, the rights in rule are merged with the existing rule.
Rules cannot be merged if they have different inheritance flags. For example, if a user is allowed read access with no inheritance flags, and RegistrySecurity.AddAccessRule(RegistryAccessRule) is used to add a rule giving the user write access with inheritance for subkeys (InheritanceFlags.ContainerInherit), the two rules cannot be merged.
Rules with different System.Security.AccessControl.AccessControlType values are never merged.
Rules express rights in the most economical way. For example, if a user has RegistryRights.QueryValues, RegistryRights.Notify and RegistryRights.ReadPermissions rights, and you add a rule allowing RegistryRights.EnumerateSubKeys rights, the user has all the constituent parts of RegistryRights.ReadKey rights. If you query the user's rights, you will see a rule containing RegistryRights.ReadKey rights. Similarly, if you remove RegistryRights.EnumerateSubKeys rights, the other constituents of RegistryRights.ReadKey rights will reappear.