第 26 题 ( R! f+ a0 h8 _' k% N2 h
请使用下面的条件确定一个类型: \- h, J% Z2 q- |% Q0 C
1) 是一个数字。
2 f4 Z5 y4 R, U N2) 不大于 65,535
7 p; g8 z8 S5 ]1 \$ V+ E" m请问,是哪一个类型?
" C6 d3 L5 o$ J/ Y$ d$ v; V7 oA. System.UInt16 6 \ A4 [1 ^; C. }
B. int ! g4 }8 d( U: z2 o
C. System.String
! B4 T, O6 _$ g$ \2 N, L* t8 HD. System.IntPtr
) Y; j* `! b2 O. u' L答案: A
% P# J" d9 z7 o0 J* C3 p5 x8 z) U% N! z6 U, L* Q
第 27 题 . C# f% N% F+ W Y' e
你正在写用户验证和授权的代码。username, password, 和roles存储在你的应用数据存储区。 : B3 c" s k/ p: N0 y
你需要建立一个用于授权检查的用户安全上下文,例如IsInRole。你写如下的代码段去验证用户:
. g/ |& h) v+ j, \+ \* c Eif (!TestPassword(userName, password)) ( B6 E L6 |2 ^0 S$ T7 Y N3 i. R
throw new Exception("could not authenticate user"); ! x$ B K. h4 x
String[] userRolesArray =LookupUserRoles(userName);
. _- D- Z" t4 ]7 r7 ~0 H你需要完成这段代码从而为用户建立安全上下文。你应该使用那个代码段? 0 s1 K$ v( B1 e2 Q- r% E; o
A. GenericIdentity ident = new GenericIdentity(userName);
% j9 k; `. g( d5 T7 c) c0 `& [GenericPrincipal currentUser = new GenericPrincipal(ident, userRolesArray); 0 O% Q5 L2 @7 }8 g; [( F k' G9 g
Thread.CurrentPrincipal = currentUser; ! V. R. q/ G) d$ |4 a
B. WindowsIdentity ident = new WindowsIdentity(userName);WindowsPrincipal currentUser = . X* [: K) K* o: P! U5 z- D7 m
new WindowsPrincipal(ident);Thread.CurrentPrincipal = currentUser; 2 z1 B& t2 g' t$ C6 U: O0 Q
C. NTAccount userNTName = new NTAccount(userName);GenericIdentity ident = new - j; `6 }+ o8 o l8 u V
GenericIdentity(userNTName.Value);GenericPrincipal currentUser= new
4 \7 }- V ^4 N4 p8 w/ A$ G# sGenericPrincipal(ident, userRolesArray);Thread.CurrentPrincipal = currentUser;
. q5 O; b5 e8 i& i& ~% r$ S- lD. IntPtr token = IntPtr.Zero;token = LogonUserUsingInterop(username,
9 [) P' J. n- B4 _* B, G/ F6 BencryptedPassword);WindowsImpersonationContext ctx =
( w; Y5 m2 y+ {7 E8 _4 \WindowsIdentity.Impersonate(token); & ^) i* }) a# a1 k$ \0 C
答案: A % S- e" d5 g4 a2 ?/ L
2 g6 |! a- @& G! Y5 H" A第 28 题 2 I: P7 C0 |$ {9 |, A& I0 s
你正在为一个 Hong Kong 的客户开发一个应用。你需要为本地的货币显示一个符号。你应该使
) h/ x* w% e' `8 `$ b用那段代码?
) j4 h. r% j) u' d8 W0 i7 FA. NumberFormatInfo culture = new CultureInfo("zh-HK").NumberFormat; * T7 X \ y; |! {- ~1 y6 g
culture.NumberNegativePattern = 1; return numberToPrint.ToString("C", culture); X1 ]/ x- r6 H$ T# k7 a; W
B. NumberFormatInfo culture = new CultureInfo("zh-HK").NumberFormat;
3 Q+ `0 A5 P# N, j1 Vculture.CurrencyNegativePattern = 1; return numberToPrint.ToString("C", culture);
( X. |4 f( l/ A7 @C. CultureInfo culture = new CultureInfo("zh-HK");return numberToPrint.ToString("-(0)",
( ?( l% i/ G0 d3 i1 tculture); 9 s7 F( f6 |0 E( b9 G
D. CultureInfo culture = new CultureInfo("zh-HK"); return numberToPrint.ToString("()", culture);
1 ]9 o" ~! b( K2 ]) @' D答案: B |