第 11 题 + V1 Q; z( F* i) a# L; q
你写了如下一段代码 public delegate void FaxDocs(object sender, FaxArgs args); 5 [' ` g% l; P3 X! F" Z- b) d8 d
你需要创建一个调用FaxDocs的事件,你应该使用那个代码段? + g( b; Q& B+ l! [4 n. \; H9 O
A. pulic static event FaxDocs Fax;
k& }7 ?* c7 rB. public static event Fax FaxDocs; : a W$ Q% x9 ]1 i( f
C. public class FaxArgs : EventArgs {
/ S7 u% O7 U# @: \4 \private string coverPageInfo; ) F q. U7 U; x9 E2 l5 Q! ~0 V
public FaxArgs(string coverInfo) {
" A& e# I. k p# v0 k, Kthis.coverPageInfo = coverPageInfo;
. L& v$ n/ u. e1 r0 n r}
n" T# ]9 [9 ?( a7 @$ qpublic string CoverPageInformation { / n$ a7 f7 W! t0 ]+ E
get {return this.coverPageInfo;} ( @. g/ p# `) h
}}
. b. j% }; G/ j6 X0 L* fD. public class FaxArgs : EventArgs { 0 U$ ?/ a" |- ]1 J
private string coverPageInfo; * A% v4 v6 x9 q
public string CoverPageInformation {
; u8 m3 T6 l$ A9 gget {return this.coverPageInfo;}
' Q8 y) O0 ^4 a9 ]6 Z}} 5 a* [; l4 _/ x' W$ P+ W
答案: A
) J) L+ m2 r: ~7 R& H8 s$ ^3 D
! c4 ?: J6 |; c L第 12 题 3 t: _, l( N9 H7 _4 ?' V
你写如下的代码段去调用Win32 Application Programming Interface (API):
1 Q0 V2 e! g+ X. Nstring personName = "N?el"; b% t" k% r7 V% ^7 i. ~* D
string msg = "Welcome" + personName + "to club"!"; ; G2 M2 {& ~9 d: i
bool rc =User32API.MessageBox(0, msg, personName, 0);
& y$ X3 G" n$ A. ~( V& X为了实现上面的调用,你需要定义一个方法原型,请问,你会采用那个代码段进行定义?
$ q1 |# P A1 S PA. [DllImport("user32", CharSet = CharSet.Ansi)] ! y L5 R$ g5 S% h9 m- U% ]
public static extern bool MessageBox(int hWnd,String text,String caption,uint type);} 1 }4 B3 K( X! P7 Z" _6 f
B. [DllImport("user32", EntryPoint = "MessageBoxA", CharSet = CharSet.Ansi)]
H# s9 R* `6 E& b. j5 DPublic static extern bool MessageBox(int hWnd,
8 J! e: s) y& ^% z8 b[MarshalAs(UnmanagedType.LPWStr)]String text,
+ [& o" c- f r7 Z; f7 b[MarshalAs(UnmanagedType.LPWStr)]String caption,
! E1 Z$ i; ^2 L- z, auint type);}
W H- r. b5 j2 b! SC. [DllImport("user32", CharSet = CharSet.Unicode)]
* v5 s- o- |+ f9 Z% {7 R/ Dpublic static extern bool MessageBox(int hWnd,String text, String caption,uint type);}
. s8 D# v/ z0 d9 Y% RD. [DllImport("user32", EntryPoint = "MessageBoxA", CharSet = ) {( v) `' a8 L8 F$ C) G$ C8 s
CharSet.Unicode)]public static extern bool MessageBox(int hWnd, & N6 |! }9 K, G5 V( F
[MarshalAs(UnmanagedType.LPWStr)]String text,
3 V9 S& @: |' f: c- v[MarshalAs(UnmanagedType.LPWStr)]String caption,uint type);}
# ]! U1 E& u6 F1 _9 G& k7 o% H答案:C
" e" j N/ d! `2 a2 U% L+ o0 U0 L6 x) x. R# M8 u
第 13 题 ( a; G- r7 K5 @$ C* x5 H3 E3 z
你需要以字符串的形式返回isolated storage文件内容。已知,文件名称为Settings.dat并且在机 + _; L0 Q0 n: m$ X
器范围内唯一。你应该使用下面那个代码段? 9 ?4 v$ @$ n. V1 u& W( z( Y* M% O
A. IsolatedStorageFileStream isoStream;isoStream = new IsolatedStorageFileStream(
) _9 N9 M2 }. e4 p3 L"Settings.dat", FileMode.Open); string result = new StreamReader(isoStream).ReadToEnd(); & ?6 R. h" _. T% E+ t
B. IsolatedStorageFile isoFile;isoFile = IsolatedStorageFile.GetMachineStoreForAssembly(); $ z9 p8 l6 u4 h* p" }$ v
IsolatedStorageFileStream isoStream;isoStream = new IsolatedStorageFileStream(
$ F9 i, e- G# m0 ]3 d"Settings.dat", FileMode.Open, isoFile); string result = new 7 V k v2 s5 Z u+ J* q$ h
StreamReader(isoStream).ReadToEnd(); 5 E( M8 X; k8 a
C. IsolatedStorageFileStream isoStream;isoStream = new
& s5 }( s, E; ]8 [' @6 f M5 A: ~& kIsolatedStorageFileStream("Settings.dat", FileMode.Open); string result =
$ F3 q% P2 d# q0 JisoStream.ToString(); x1 O, G% e0 t4 K4 S0 Z
D. IsolatedStorageFile isoFile;isoFile = IsolatedStorageFile.GetMachineStoreForAssembly();
* q/ i6 ^5 _$ i, D9 ~) yIsolatedStorageFileStream isoStream;isoStream = new IsolatedStorageFileStream( : {- P- d$ f8 o. x' q. ?
"Settings.dat", FileMode.Open, isoFile); string result = isoStream.ToString(); ; T$ l4 C4 x/ h+ J/ Z
答案: B |