163.You are developing a class library. Portions of your code need to access system environment variables. You
need to force a runtime SecurityException only when callers that are higher in the call stack do not have the
necessary permissions. Which call method should you use?
A. set.Demand();
B. set.Assert();
C. set.PermitOnly();
D. set.Deny();
求解
正确答案应该是哪个?

解决方案 »

  1.   

    这个问题很简单,答不出的要么不看MSDN要么英文太差...不给答案,给出参考自已看...还看不出就该去面壁了...You need to force a runtime SecurityException only when callers that are higher in the call stack do not have the necessary permissionsDemand 要求调用堆栈中的所有高级调用方都已被授予了当前权限对象所指定的权限...
    Assert 即使堆栈中的高级调用方未被授予访问当前权限对象所标识资源的权限,调用代码仍能访问该资源...
    PermitOnly 即使代码已被授予访问其他资源的权限,也只能访问此权限对象所指定的资源...
    Deny 即使调用方已被授予访问当前权限对象所指定资源的权限,调用方访问该资源的能力仍被拒绝...