1. 您正在编写自定义字典。该自定义字典类名为MyDictionary。 您需要确保该字典是类型安全的字典。 您应该使用哪个代码段?
A. class MyDictionary :Dictionary
MyDictionary dictionary = (MyDictionary)t; Answer: A
2. 您正在创建名为Age 的类。
您需要确保编写的Age 类的对象所构成的集合能够被排序。 您应该使用哪个代码段?
A. public class Age { public int Value;
public object CompareTo(object obj) { if (obj is Age) {
Age _age = (Age) obj;
return Value.CompareTo(obj); }
throw new ArgumentException(\} }
B. public class Age { public int Value;
public object CompareTo(int iValue) { try {
return Value.CompareTo(iValue); } catch {
throw new ArgumentException (\} } }
C. public class Age :IComparable { public int Value;
public int CompareTo(object obj) { if (obj is Age) {
Age _age = (Age) obj;
return Value.CompareTo(_age.Value); }
throw new ArgumentException(\} }
D. public class Age :IComparable { public int Value;
public int CompareTo(object obj) { try {
return Value.CompareTo(((Age) obj).Value); } catch { return -1; } } }
Answer: C
3. 您正在创建一个类,用于比较经过特殊格式设置的字符串。默认的排序规则比较不适用。 您需要实现IComparable
A. public class Person :IComparable
B. public class Person :IComparable
C. public class Person :IComparable
D. public class Person :IComparable
Answer: A
4. 您正在开发自定义集合类。 您需要在类中创建方法。
您需要确保在类中创建的方法返回与Foreach 语句兼容的类型。 该方法应满足哪个条件?
A. 该方法必须返回IEnumerator 或IEnumerable 类型。 B. 该方法必须返回IComparable 类型。
C. 该方法必须明确包含集合。
D. 该方法必须是类中唯一的迭代器。 Answer: A
5. 您正在开发一个协助用户进行电子调查的应用程序。调查由25 个对错判断题组成。 您需要执行下列任务: ·将每个答案预置为是。
·最大程度地减少每次调查使用的内存量。 您应该选择哪个存储选项?
A. BitVector32 answers = new BitVector32(1); B. BitVector32 answers = new BitVector32(-1); C. BitArray answers = new BitArray (1); D. BitArray answers = new BitArray(-1); Answer: B
6. 您需要确定满足下列条件的类型: 始终为数字。 不大于65,535。 您应选择哪种类型? A. System.UInt16 B. int
C. System.String D. System.IntPtr Answer: A
7.您正在开发一个自定义事件处理程序,自动打印所有打开的文件。事件处理程序有助于指定打印的份数。你需要开发一个自定义事件的参数类作为参数传递给事件处理程序。您应该使用哪个代码段?
A. public class PrintingArgs { private int copies;
public PrintingArgs(int numberOfCopies) { this.copies = numberOfCopies; } public int Copies { get { return this.copies; } }}
B. public class PrintingArgs : EventArgs { private int copies;
public PrintingArgs(int numberOfCopies) { this.copies = numberOfCopies; } public int Copies { get { return this.copies; } }} C. public class PrintingArgs { private EventArgs eventArgs;
public PrintingArgs(EventArgs ea) { this.eventArgs = ea; }
public EventArgs Args {get { return eventArgs; }}}
D. public class PrintingArgs : EventArgs { private int copies;} Answer: B
8. 您编写一个名为Employee 的类,该类包含以下代码段。 public class Employee {
string employeeId, employeeName, jobTitleName; public string GetName() { return employeeName; } public string GetTitle() { return jobTitleName; } 您需要在类型库中向COM 公开此类。COM 接口还必须便于在Employee 类的新版本之间保持向前兼容。
您需要选择方法以生成COM 接口。 您应该怎么做?
A. 将以下属性添加到类定义。
[ClassInterface(ClassInterfaceType.None)] public class Employee {
B. 将以下属性添加到类定义。
[ClassInterface(ClassInterfaceType.AutoDual)] public class Employee {
C. 将以下属性添加到类定义。 [ComVisible(true)]
public class Employee {
D. 为类定义接口并将以下属性添加到类定义。 [ClassInterface(ClassInterfaceType.None)] public class Employee :IEmployee { Answer: D
9. 您需要通过使用平台调用服务从托管代码中调用非托管函数。您应该做些什么? A.创建一个类支持DLL函数,然后使用托管代码创建原型方法。 B.使用COM注册你的程序集,然后从COM中参考你的托管代码。 C.为托管代码创建一个类库。
D.导入一个类库。然后创建COM对象的实例 Answer: A
10. 您正在写的下面的代码是,调用一个函数从Win32应用程序编程接口( API )通过使用平台调用。
A. [DllImport(\
public static extern int MessageBox(int hWnd, String text, String caption, uint type); B. [DllImport(\
public static extern int MessageBoxA(int hWnd,String text, String caption, uint type); C. [DllImport(\
public static extern int Win32API_User32_MessageBox(int hWnd, String text, String caption, uint type);
D. [DllImport(@\
public static extern int MessageBox(int hWnd, String text, String caption, uint type); Answer: A
11.您创建了一个应用程序发送邮件的电子邮箱。 在你的本地服务器上有一个有效的SMTP服务器。SMTP服务器的名称smtp.contoso.com 。要测试应用程序,您使用的源地址是:me@contoso.com ,并发送信息到目标地址:you@contoso.com 。该代码段应该使用哪一段?
A. MailAddress addrFrom = new MailAddress(\ MailAddress addrTo = new MailAddress(\ MailMessage message = new MailMessage(addrFrom, addrTo);
message.Subject = \ B. string strSmtpClient = \ string strFrom = \ string strTo = \ string strSubject = \ string strBody = \
MailMessage msg = new MailMessage(strFrom, strTo, strSubject, strSmtpClient); C. MailAddress addrFrom = new MailAddress(\ MailAddress addrTo = new MailAddress(\ MailMessage message = new MailMessage(addrFrom, addrTo); message.Subject = \ message.Body = \
SmtpClient client = new SmtpClient(\ client.Send(message);
D. MailAddress addrFrom = new MailAddress(\ MailAddress addrTo = new MailAddress(\ MailMessage message = new MailMessage(addrFrom, addrTo); message.Subject = \ message.Body = \
SocketInformation info = new SocketInformation(); Socket client = new Socket(info);