4.你写了如下一段代码 public delegate void FaxDocs(object sender, FaxArgs args);
你需要创建一个调用FaxDocs的事件,你应该使用那个代码段?
A. pulic static event FaxDocs Fax;
B. public static event Fax FaxDocs;
C. public class FaxArgs : EventArgs {
private string coverPageInfo;
public FaxArgs(string coverInfo) {
this.coverPageInfo = coverPageInfo;
}
public string CoverPageInformation {
get {return this.coverPageInfo;}
}}
D. public class FaxArgs : EventArgs {
private string coverPageInfo;
public string CoverPageInformation {
get {return this.coverPageInfo;}
}}
答案: A
5.你写如下的代码段去调用Win32 Application Programming Interface (API):
string personName = "N?el";
string msg = "Welcome" + personName + "to club"!";
bool rc =User32API.MessageBox(0, msg, personName, 0);
为了实现上面的调用,你需要定义一个方法原型,请问,你会采用那个代码段进行定义?
A. [DllImport("user32", CharSet = CharSet.Ansi)]
public static extern bool MessageBox(int hWnd,String text,String caption,uint type);}
B. [DllImport("user32", EntryPoint = "MessageBoxA", CharSet = CharSet.Ansi)]
Public static extern bool MessageBox(int hWnd,
[MarshalAs(UnmanagedType.LPWStr)]String text,
[MarshalAs(UnmanagedType.LPWStr)]String caption,
uint type);}
C. [DllImport("user32", CharSet = CharSet.Unicode)]
public static extern bool MessageBox(int hWnd,String text, String caption,uint type);}
D. [DllImport("user32", EntryPoint = "MessageBoxA", CharSet =
CharSet.Unicode)]public static extern bool MessageBox(int hWnd,
[MarshalAs(UnmanagedType.LPWStr)]String text,
[MarshalAs(UnmanagedType.LPWStr)]String caption,uint type);}
答案:C
微软认证考试
6.你需要以字符串的形式返回isolated storage文件内容。已知,文件名称为Settings.dat并且在机
器范围内唯一。你应该使用下面那个代码段?
A. IsolatedStorageFileStream isoStream;isoStream = new IsolatedStorageFileStream(
"Settings.dat", FileMode.Open); string result = new StreamReader(isoStream).ReadToEnd();
B. IsolatedStorageFile isoFile;isoFile = IsolatedStorageFile.GetMachineStoreForAssembly();
IsolatedStorageFileStream isoStream;isoStream = new IsolatedStorageFileStream(
"Settings.dat", FileMode.Open, isoFile); string result = new
StreamReader(isoStream).ReadToEnd();
C. IsolatedStorageFileStream isoStream;isoStream = new
IsolatedStorageFileStream("Settings.dat", FileMode.Open); string result =
isoStream.ToString();
D. IsolatedStorageFile isoFile;isoFile = IsolatedStorageFile.GetMachineStoreForAssembly();
IsolatedStorageFileStream isoStream;isoStream = new IsolatedStorageFileStream(
"Settings.dat", FileMode.Open, isoFile); string result = isoStream.ToString();
答案: B