微软认证考试网整理了关于微软考试复习资料,希望对复习考试有所帮助,以下是关于2012年
微软认证考试备考模拟试题,祝愿大家取得好成绩。
15.你正在写用户验证和授权的代码。username, password, 和roles存储在你的应用数据存储区。
你需要建立一个用于授权检查的用户安全上下文,例如IsInRole。你写如下的代码段去验证用户:
if (!TestPassword(userName, password)) ,
throw new Exception("could not authenticate user");
String[] userRolesArray =LookupUserRoles(userName);
你需要完成这段代码从而为用户建立安全上下文。你应该使用那个代码段?
A. GenericIdentity ident = new GenericIdentity(userName);
GenericPrincipal currentUser = new GenericPrincipal(ident, userRolesArray);
Thread.CurrentPrincipal = currentUser;
B. WindowsIdentity ident = new WindowsIdentity(userName);WindowsPrincipal currentUser =
new WindowsPrincipal(ident);Thread.CurrentPrincipal = currentUser;
C. NTAccount userNTName = new NTAccount(userName);GenericIdentity ident = new
GenericIdentity(userNTName.Value);GenericPrincipal currentUser= new
GenericPrincipal(ident, userRolesArray);Thread.CurrentPrincipal = currentUser;
D. IntPtr token = IntPtr.Zero;token = LogonUserUsingInterop(username,
encryptedPassword);WindowsImpersonationContext ctx =
WindowsIdentity.Impersonate(token);
答案: A
16.你正在为一个 Hong Kong 的客户开发一个应用。你需要为本地的货币显示一个符号。你应该使
用那段代码?
A. NumberFormatInfo culture = new CultureInfo("zh-HK").NumberFormat;
culture.NumberNegativePattern = 1; return numberToPrint.ToString("C", culture);
B. NumberFormatInfo culture = new CultureInfo("zh-HK").NumberFormat;
culture.CurrencyNegativePattern = 1; return numberToPrint.ToString("C", culture);
C. CultureInfo culture = new CultureInfo("zh-HK");return numberToPrint.ToString("-(0)",
culture);
D. CultureInfo culture = new CultureInfo("zh-HK"); return numberToPrint.ToString("()", culture);
答案: B
17.请使用下面的条件确定一个类型:
1) 是一个数字。
2) 不大于 65,535
请问,是哪一个类型?
A. System.UInt16
B. int
C. System.String
D. System.IntPtr
答案: A