第 39 题
- k" h2 J( ~2 q) t你正在创建一个执行复杂财务运算的类。这个类包含一个方法 GetCurrentRate,它得到当前
" k" \& S, e8 o的汇率并保存在变量 currRate 中。你为此类实现了序列化。为此,你需要写一段代码,当类被 7 l% G: E$ A ~( j2 S1 ^" _
反序列化后,能够使用当前的实际汇率更新 currRate 变量。你应该使用下面那段代码? : U( Y [! a' z. L( u0 M
A. [OnSerializing]internal void UpdateValue (StreamingContext context) { 9 @, a" j% Q9 T, w; B7 r; Z
currRate = GetCurrentRate();}
1 q& n1 u; i/ Z+ nB. [OnSerializing]internal void UpdateValue(SerializationInfo info)
+ q( `! ~. A1 L& \4 z* L) \9 D& J. f{info.AddValue("currentRate", GetCurrentRate());}
- d2 a* ~. ~$ Z( HC. [OnDeserializing]internal void UpdateValue(SerializationInfo info) { * o# e- O* R; e
info.AddValue("currentRate", GetCurrentRate());}
9 I3 a( d( C1 x8 E5 W) GD. [OnDeserialized]internal void UpdateValue(StreamingContext context) { & \) a$ C8 H* z( P5 n
currRate = GetCurrentRate();}
! G% J( H, A9 n2 l8 W答案: D , O; [8 {4 R3 l
8 E; r0 H5 K' {$ \第 40 题
# y- N9 E, h' i0 m4 s+ z# M- Z你正在写一个使用独立存储区(isolated storage)存储用户参数信息的应用。应用使用了多
" g0 t* }2 n; o' T个程序集,而且多个用户将会在同一个机器上使用此应用。你需要在当前的 Microsoft ; O3 E& V6 I7 P0 k S5 ?0 }
Windows 标识和程序集的独立存储区内创建一个目录 Preferences。你应该使用下面那段代
! P; K: F& B* t3 v0 v) J# \码? ) B4 Q* \/ A8 x
A. IsolatedStorageFile store;store = 3 ~* j |7 A4 X+ }
IsolatedStorageFile.GetUserStoreForAssembly();store.CreateDirectory("Preferences");
- @6 f$ D9 H0 f8 r! u& l- V. YB. IsolatedStorageFile store;store =
, u# b. q; ]9 CIsolatedStorageFile.GetMachineStoreForAssembly();store.CreateDirectory("Preferences");
+ L7 x# p- u I3 @C. IsolatedStorageFile store;store = ( l- |9 M; P' b# b% p1 H
IsolatedStorageFile.GetUserStoreForDomain();store.CreateDirectory("Preferences");
! u9 w2 L! d7 N' Z# `0 c& q. ^D. IsolatedStorageFile store;store =
9 M0 H' b$ K2 @ q: x9 j$ UIsolatedStorageFile.GetMachineStoreForApplication();store.CreateDirectory("Preferences");
4 p% j# m ^& q答案: A |