A declarative demand is a technique for invoking a security check without adding any statements to your code. You make a declarative demand by placing information at the class or member level, indicating the permissions you want your callers to have. If you place a declarative security check at the class level, the security check applies to each member of the class. However, if you place a declarative security check at the member level, it applies to only that member and it overrides the permission specified at the class level, if there is one.
For example, suppose you specify at the class level that PermissionA is required, and for that class's Method1 you indicate that PermissionB is required. When Method 1 is called, a security check will look for only PermissionB, but other methods of the class still require PermissionA.
You might choose declarative demands if you are using a tool that makes them easier to apply than imperative checks. Some demands, such as link-demand and inheritance demands, can only be applied declaratively.
Link-demands and inheritance demands, which protect your assemblies from unauthorized callers, are sometimes useful if your application consists of more than one assembly. The security checks that result from link-demands and inheritance demands occur at JIT compilation time instead of execution time. Link-demands, which can be placed either at the method or class level, ensure that only code that has been granted the demanded permission can bind (through calls or references) to your code. Care must be taken when using link-demands to secure your code because only the immediate caller is checked instead of all the callers in the call stack. Also, it's important to understand that exceptions thrown when link-demands fail cannot be caught by user code. Inheritance demands can be placed at the class level to ensure that only code with the specified permission can inherit from your class. Inheritance demands placed on methods require code to have the specified permission in order to overload the method.