.NET C题库

上传人:cn****1 文档编号:553051341 上传时间:2024-02-24 格式:DOC 页数:40 大小:219.50KB
返回 下载 相关 举报
.NET C题库_第1页
第1页 / 共40页
.NET C题库_第2页
第2页 / 共40页
.NET C题库_第3页
第3页 / 共40页
.NET C题库_第4页
第4页 / 共40页
.NET C题库_第5页
第5页 / 共40页
点击查看更多>>
资源描述

《.NET C题库》由会员分享,可在线阅读,更多相关《.NET C题库(40页珍藏版)》请在金锄头文库上搜索。

1、第 1 题你正在开发一个自定义事件处理去自动打印所有打开的文档。事件处理可以指定要打印的份数。为此,你需要开发一个传递给事件处理程序的自定义事件参数类,你应该使用下面那个代码段?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

2、 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 PrintingAr

3、gs : EventArgs private int copies;第 2 题你使用反射(Reflection)来获得方法MyMethod 的信息。你需要获取 MyMethod方法是否在派生类中可以访问,你应该如何做?A.访问MethodInfo的IsAssembly属性。B.访问MethodInfo的IsVirtual属性。C.访问MethodInfo的IsStatic属性。D.访问MethodInfo的IsFamily属性。第 3 题你正在创建一个使用非托管资源的类。这个类引用了使用托管资源的对象。你需要确保使用这个类的用户在不需要类实例的时候能够够释放资源。你应该做那三个工作?(每个答案

4、是解决方案的一部分)A.定义一个从WeakReference继承的类。B.定义一个实现IDisposable接口的类。C.创建一个类析构函数,调用其它对象的方法去释放托管资源。D.创建一个类析构函数,释放非托管资源E.创建一个Dispose方法,调用System.GC.Collect强制垃圾回收。F.创建一个Dispose方法,释放非托管资源并且调用其它对象的方法释放托管资源。第 4 题你正对一个应用进行调试。你需要找到引起异常的代码行。请问,Exception类的哪个属性能达到这个目的?A. DataB. MessageC. StackTraceD. Source第 5 题你正在测试一个新开

5、发的方法 PersistToDB。这个方法接收一个类型为 EventLogEntry 的参数,方法没有返回值。你需要创建一段代码来帮助你测试这个方法。这段代码必须从本地计算机的应用日志读取日志项然后传递日志项给 PersistToDB 方法。要求,传递到 PersistToDB 方法的日志项必须是 MySource 源而且类型为错误或警告的日志。你应该使用下面那个代码段?A. EventLog myLog = new EventLog(“Application”, “.”);foreach (EventLogEntry entry in myLog.Entries)if (entry.Sour

6、ce = MySource)PersistToDB(entry);B. EventLog myLog = new EventLog(“Application”, “.”);myLog.Source = “MySource”;foreach (EventLogEntry entry in myLog.Entries)if (entry.EntryType = (EventLogEntryType.Error &EventLogEntryType.Warning)PersistToDB(entry);C. EventLog myLog = new EventLog(“Application”, “

7、.”);foreach (EventLogEntry entry in myLog.Entries)if (entry.Source = MySource)if (entry.EntryType = EventLogEntryType.Error |entry.EntryType =EventLogEntryType.Warning)PersistToDB(entry);D. EventLog myLog = new EventLog(“Application”, “.”);myLog.Source = “MySource”;foreach (EventLogEntry entry in my

8、Log.Entries)if (entry.EntryType = EventLogEntryType.Error |entry.EntryType = EventLogEntryType.Warning)PersistToDB(entry);第 6 题你的应用使用两个名为 threadOne 和 threadTwo 的线程。你需要修改代码使其只有 threadTwo执行完成才开始执行 threadOne。你应该如何做?A.设置threadOne运行在低优先级。B.设置threadTwo运行在高优先级。C.使用WaitCallback 代理去同步线程。D.调用threadOne的Sleep方法

9、。第 7 题你是公司 A 的一个开发人员。你创建了一个名为 Company1 的程序集。Company1 包含了一个 public 方法。全局程序集中包含了另一个名为 Company2 的程序集。你必须保证,public 方法只能够被 Company2 调用。你需要使用下面哪个权限类?A. GacIdentityPermissionB. PublisherIdentityPermissionC. DataProtectionPermissionD. StrongNameIdentityPermission第 8 题你创建了一个发送 e-mail 的应用。一个名称为 smtp.C 的 SMTP

10、服务器在本地子网是可用的 。 为 了 测 试 应 用 , 你 使 用 源 地 址 为meC , 目 标 地 址 为youC。你应该使用下面那个代码段去发送 e-mail?A. MailAddress addrFrom =new MailAddress(“meC”, “Me”);MailAddress addrTo =new MailAddress(“youC”, “You”);MailMessage message = newMailMessage(addrFrom, addrTo);message.Subject = “Greetings!”;message.Body =“Test”;mes

11、sage.Dispose();B. string strSmtpClient = “mstp.C”;string strFrom = “meC”;String strTo= “youC”;string strSubject = “Greetings!”;string strBody = “Test”;MailMessagemsg = new MailMessage(strFrom, strTo, strSubject, strSmtpClient);C. MailAddress addrFrom = new MailAddress(“meC”);MailAddress addrTo =newM

12、ailAddress(“youC”);MailMessage message = newMailMessage(addrFrom,addrTo);message.Subject = “Greetings!”;message.Body = “Test”;SmtpClient client = newSmtpClient(“smtp.C”);client.Send(message);D. MailAddress addrFrom =new MailAddress(“meC”, “Me”);MailAddress addrTo = newMailAddress(“youC”, “You”);Mail

13、Message message = newMailMessage(addrFrom, addrTo);message.Subject = “Greetings!”;message.Body =“Test”;SocketInformation info = new SocketInformation();Socket client = newSocket(info);System.Text.ASCIIEncoding enc = new System.Text.ASCIIEncoding();bytemsgBytes = enc.GetBytes(message.ToString();clien

14、t.Send(msgBytes);第 9 题你正在开发一个自定义集合类。你需要在你的类里创建一个方法而且能够保证你的方法的返回值是一个能够适合 Foreach 语句使用的类型。你应该如何实现你的方法?A.方法必须返回一个IEnumerator或Ienumerable的类型。B.方法必须返回一个IComparable的类型。C.方法必须包含一个集合。第 10 题你正在开发一个执行数学计算的应用。你创建了一个类 CalculationValues,并且写了一个操作 CalculationValues 的过程 PerformCalculation。你需要保证当计算被执行的时候,用户界面能够继续响应。为此,你需要写一个代码段去调用 PerformCalculation 过程去达到目的,你应该使用下面那个代码段?A. private void PerformCalculation() . private void DoWork()Calculation Values myValues = new Calculation Values();Thread newThread = new Thread(new ThreadStart(PerformCalculation);new Thread.Start(myValues);

展开阅读全文
相关资源
相关搜索

当前位置:首页 > 生活休闲 > 科普知识

电脑版 |金锄头文库版权所有
经营许可证:蜀ICP备13022795号 | 川公网安备 51140202000112号