70-536中文题库(带解析)

更新时间:2024-06-27 10:42:01 阅读量: 综合文库 文档下载

说明:文章内容仅供预览,部分内容可能不全。下载后的文档,内容与下面显示的完全一致。下载之前请确认下面内容是否您想要的,是否完整无缺。

1. 您正在编写自定义字典。该自定义字典类名为MyDictionary。 您需要确保该字典是类型安全的字典。 您应该使用哪个代码段?

A. class MyDictionary :Dictionary B. class MyDictionary :HashTable C. class MyDictionary :IDictionary D. class MyDictionary { ...} Dictionary t = new Dictionary();

MyDictionary dictionary = (MyDictionary)t; Answer: A

解析:6115A 第二章 泛型集合 因为要创建一个MyDictionary类,又是要求类型安全的类。则需要类继承一个类型安全的类,即泛型。泛型的语法:Dictionary<类型,类型,…>。所以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

解析:6115A P26页

因为需要创建的类的对象的集合可以排序,所以需要继承排序的类或者接口。排除法,可以排除A和B。从C和D中选择其一,C和D的区别是,C是判断两个对象是否相同,而D考虑的问题不全面,它没有考虑要比较的对象应该是Age,所以应该选择C。

3. 您正在创建一个类,用于比较经过特殊格式设置的字符串。默认的排序规则比较不适用。 您需要实现IComparable 接口。 您应该使用哪个代码段?

A. public class Person :IComparable{ public int CompareTo(string other){ ... } }

B. public class Person :IComparable{ public int CompareTo(object other){ ... } }

C. public class Person :IComparable{ public bool CompareTo(string other){ ... } }

D. public class Person :IComparable{

public bool CompareTo(object other){ ... } }

Answer: A 6115A

P26页

解析:因为题目要求是实现接口IComparable,都需要继承这个接口,这是毫无疑问的,就在于方法的实现了,这就需要知道这个接口中的方法是哪个,可以知道,此接口仅包含一个方法:CompareTo(),返回值小于0表示当前对象小于被比较的对象,返回值等于0表示两个对象相等,返回值大于0表示当前对象大于被比较的对象。这个接口的方法,是返回的int值。所以A和B中选一个。又因为这个方法要求的是比较字符串类型的变量,所以参数应该是字符串类型。所以选A。

4. 您正在开发自定义集合类。 您需要在类中创建方法。

您需要确保在类中创建的方法返回与Foreach 语句兼容的类型。 该方法应满足哪个条件?

A. 该方法必须返回IEnumerator 或IEnumerable 类型。 B. 该方法必须返回IComparable 类型。 C. 该方法必须明确包含集合。

D. 该方法必须是类中唯一的迭代器。 Answer: A

解析:6115A 第二章 P4

因为需要返回一个与foreach语句兼容的类型,所以肯定要有一个返回值。而且返回值的类型一定是集合类型。上述答案中只有IEnumerator 或IEnumerable类型集合类型的返回值。所以选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

解析:第二章 P33

此题考察的是BitVector32 和 BitArray的区别。

对于内部使用的布尔值和小整数,BitVector32 比 BitArray 更有效。BitArray 可以按需要

无限地扩大,但它有内存和性能方面的系统开销.

位向量bitVector32, 用默认构造函数创建了一个BitVector32,其中所有的32位都初始化为false。构造函数传入的值如果为1,则结果会再加1,相当于结果没有变化,所以还是false,即应传入-1来表示结果做了取反的变化。是数据结构中的内容。

6. 您需要确定满足下列条件的类型: 始终为数字。 不大于65,535。 您应选择哪种类型? A. System.UInt16 B. int

C. System.String D. System.IntPtr Answer: A

解析:第一章:P3

因为65535最接近的数字为2的16次方的。又因为是数字类型,所以是Uint16,主要考察类型的取值范围。

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

解析:课本第七章P23页

此题是在写一个自定义的事件处理程序,所以最先判断应该继承一个事件处理程序的类,所以筛选法,把A和C去掉。看B和D,看题目要求,需要有一个参数传递功能,因为D没有参数,也就是没有构造函数的重载方法,所以应选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

解析:使用VS.Net 做.Net组件P5

这个题目有一个关键之处,需要COM接口与新版本之间保持向前兼容,所以最起码要继承某个类或者接口。所以看选项,继承了接口的答案只有D,其他的就是声明类为COM组件的方法。

9. 您需要通过使用平台调用服务从托管代码中调用非托管函数。您应该做些什么? A.创建一个类支持DLL函数,然后使用托管代码创建原型方法。 B.使用COM注册您的程序集,然后从COM中参考您的托管代码。 C.为托管代码创建一个类库。

D.导入一个类库。然后创建COM对象的实例 Answer: A

解析:回调函数是托管应用程序中可帮助非托管 DLL 函数完成任务的代码。对回调函数的

调用将从托管应用程序中,通过一个 DLL 函数,间接地传递给托管实现。在用平台调用调用的多种 DLL 函数中,有些函数要求正确地运行托管代码中的回调函数。

10. 您正在写的下面的代码是,调用一个函数从Win32应用程序编程接口( API )通过使用平台调用。

Int rc=MessageBox(hWnd,text,caption,type)

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

解析:第一章 P8

此程序从答案上看,生成的DLL的名字是user32,所以属性指出 [dllimport(“user32”)]而D指出了路径,因为已经指明是win32中的接口,所以默认调用就可以,不用再指明路径。而B和C是方法名称写错。

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);

System.Text.ASCIIEncoding enc = new System.Text.ASCIIEncoding(); byte[] msgBytes = enc.GetBytes(message.ToString()); client.Send(msgBytes); 答案: C

解析:这是一个电子邮件发送的典型示例。C答案是固定用法。

12. 您需要建立一个名为MyAssembly动态程序集。并需要保存此程序集到磁盘。应该使用哪个代码段?

A. AssemblyName myAssemblyName = new AssemblyName(); myAssemblyName.Name = \

AssemblyBuilder myAssemblyBuilder =AppDomain.CurrentDomain.DefineDynamicAssembly (myAssemblyName, AssemblyBuilderAccess.Run); myAssemblyBuilder.Save(\

B. AssemblyName myAssemblyName = new AssemblyName(); myAssemblyName.Name = \

AssemblyBuilder myAssemblyBuilder =AppDomain.CurrentDomain.DefineDynamicAssembly (myAssemblyName, AssemblyBuilderAccess.Save); myAssemblyBuilder.Save(\

C. AssemblyName myAssemblyName =new AssemblyName();

AssemblyBuilder myAssemblyBuilder = AppDomain.CurrentDomain.DefineDynamicAssembly (myAssemblyName, AssemblyBuilderAccess.RunAndSave);

myAssemblyBuilder.Save(\

D. AssemblyName myAssemblyName =new AssemblyName(\

AssemblyBuilder myAssemblyBuilder =AppDomain.CurrentDomain.DefineDynamicAssembly (myAssemblyName, AssemblyBuilderAccess.Save); myAssemblyBuilder.Save(\ 答案: B

解析:第三章 :程序集

声明一个程序集的用法,因为要指明程序集的名称,所以C错误,排除,可以看AB和D,因为A是Run,而题目要求的是保存,所在A排除,看B和D,因为创建的是动态的程序集,需要保存到默认路径下,D保存到C盘根目录底下是错误的。

13.您需要写一个代码段来执行以下任务: 检索每个暂停服务的名称

通过的名用集合的Add方法添加到集合中。 您应该用哪个代码实现?

纠正翻译:您需要写一个代码段来执行以下任务: 检索每个暂停服务的名称

通过集合名称为Collection1的Add方法添加到集合中。 您应该用哪个代码实现?

A. ManagementObjectSearcher searcher = new ManagementObjectSearcher(\Win32_Service where State = 'Paused'\

foreach (ManagementObject svc in searcher.Get()) {Collection1.Add(svc[\ B. ManagementObjectSearcher searcher = new ManagementObjectSearcher(\Win32_Service\

foreach (ManagementObject svc in searcher.Get()) { Collection1.Add(svc[\ C. ManagementObjectSearcher searcher = new ManagementObjectSearcher( \from Win32_Service\

foreach (ManagementObject svc in searcher.Get())

{if ((string) svc[\ }} D. ManagementObjectSearcher searcher =new ManagementObjectSearcher(); searcher.Scope = new ManagementScope(\ foreach (ManagementObject svc in searcher.Get())

{if ((string)svc[\ }} 答案: A

解析:此题考察的是ManagementObjectSearcher类的使用,此类的构造函数有六个重载的 ManagementObjectSearcher:用来查询暂停服务或网络中的网络

方法,其中之一就是A答案中的传入一个字符串语句。而且也考察了SQL中查询服务的方法。见MSDN,如下为示例。

ManagementObjectSearcher s = new ManagementObjectSearcher(\* FROM Win32_Service\

foreach (ManagementObject service in s.Get()) {

Console.WriteLine(service.ToString()); }

14.贵公司使用的一个名为Application1的应用程序,此程序使用的.net Framework的版本是1.0。这个应该程序已经安装在了一台共享的计算机中,此计算机中已安装了.net Framework 1.0和1.1的版本。您需要移动此应用程序到另一台计算机中,此计算机已安装.net Framework 1.1和2.0的版本。此应用程序和1.1的版本是兼容的,但是与.net

Framework2.0是不兼容的。您需要确保应用程序在新计算机上使用.net Framework的1.1版本。您将怎样做?

A. 将以下XML 元素添加到应用程序配置文件。

B. 将以下XML 元素添加到应用程序配置文件。

xmlns=\

C. 将以下XML 元素添加到计算机配置文件。

D. 将以下XML 元素添加到计算机配置文件。

xmlns=\

答案: A

解析:看题目说明,因为此应用程序是与1.1兼容的,这就好办了,只需要在应用程序的配置文件中指明此应用程序使用的.net FrameWork的版本就可以了。又因为机器上已经安装了2.0和1.1,所以使用A来配置一下就可以。指明supportedRuntime为1.1版本即可。

15.您使用的是VS2005的编译器来解析一个返回string类型的方法。您给此输出参数命名为fName,您需要写一段代码来打印信息,如果fName的值不等于John则打印:“Test Failed.”。您还需要确保该代码段不间断的执行应用程序。该代码段应该使用如下哪个选项?

纠正翻译:

您正在使用Microsoft Visual Studio IDE 检查返回字符串的方法的输出。您将该方法的输出赋给一个名

为fName 的字符串变量。

您需要编写一个代码段,该代码段在单一行中打印以下内容 · 信息:\”

· fName 的值(如果fName 的值不等于“John”) 您还需要确保代码段同时能不中断应用程序的执行。 您应该使用哪个代码段?

A. Debug.Assert(fName == \

B. Debug.WriteLineIf(fName != \

C. if (fName != \ }

D. if (fName != \ } 答案: B

解析:Debug:提供一组帮助调试代码的方法和属性。

考察的是Debug.WriteLineIf方法的使用。此方法有四个重载,此题中需要使用的方法是:WriteLineIf 方法 (Boolean, String, String)的方法的重载,第一个参数为bool值类型,第二个参数和第三个参数都是字符串类型的。作用为:如果第一个参数的值为true,则打印第二个参数的值,如果为false则打印第三个参数的值。

16.(纠正翻译) 您正在创建一个可列出远程计算机上的进程的应用程序。该应用程序需要一个执行以下任务的方法:

·以名为strComputer 的字符串参数的形式接受远程计算机名称。

·返回一个包含该计算机上正在运行的所有进程的名称的ArrayList 对象。

您需要编写一个代码段,该代码段检索远程计算机上正在运行的每个进程的名称,并将名称添加到ArrayList对象。 您应该使用哪个代码段?

A. ArrayList al = new ArrayList();

Process[] procs = Process.GetProcessesByName(strComputer); foreach (Process proc in procs) { al.Add(proc);} B. ArrayList al = new ArrayList();

Process[] procs = Process.GetProcesses(strComputer); foreach (Process proc in procs) { al.Add(proc);} C. ArrayList al = new ArrayList();

Process[] procs = Process.GetProcessesByName(strComputer); foreach (Process proc in procs) {al.Add(proc.ProcessName);} D. ArrayList al = new ArrayList();

Process[] procs = Process.GetProcesses(strComputer); foreach (Process proc in procs) {al.Add(proc.ProcessName);} 答案: D

解析:此题目主要用来得到远程计算机上的进程名称。

用的是Process类。Process[] GetProcesses(string machineName):它表示指定计算机上运行的所有进程资源。 其中ProcessName:进程名称。所以答案 ,选D.

public static Process[] GetProcessesByName (string processName):运行指定应用程序的进程资

17.您正在测试一个新开发名为PersistToDB的方法。该方法接收一个EventLog类型的参数,并且没有返回值。您需要创建一个代码段,用来帮助您测试此方法。代码段必须实现通过PersistToDB方法的输入项从本地计算机中读取log文档。代码块必须通过唯一的来自PersistToDB方法的事件类型错误或警告消息。您应该使用哪一段代码实现。

纠正翻译:您正在测试一个名为PersistToDB 的新开发的方法。此方法接受EventLogEntry 类型的参数。此方法不返回值。

您需要创建一个可帮助您测试该方法的代码段。代码段必须从本地计算机的应用程序日志中读取条目,然后将条目传递到PersistToDB 方法。代码块必须只将Error 或Warning 类型的事件从源“MySource”传递到PersistToDB 方法。 您应该使用哪个代码段

A. EventLog myLog = new EventLog(\ foreach (EventLogEntry entry in myLog.Entries)

{if (entry.Source == \ PersistToDB(entry); } } B. EventLog myLog = new EventLog(\ myLog.Source = \

foreach (EventLogEntry entry in myLog.Entries) {

if (entry.EntryType == (EventLogEntryType.Error & EventLogEntryType.Warning)) { PersistToDB(entry); }}

C. EventLog myLog = new EventLog(\ foreach (EventLogEntry entry in myLog.Entries) { if (entry.Source == \

{if (entry.EntryType == EventLogEntryType.Error | entry.EntryType == EventLogEntryType.Warning) {PersistToDB(entry); } } }

D. EventLog myLog = new EventLog(\ myLog.Source = \

foreach (EventLogEntry entry in myLog.Entries)

{if (entry.EntryType == EventLogEntryType.Error | entry.EntryType == EventLogEntryType.Warning) {PersistToDB(entry); } 答案: C 解释:第四章

此题主要考察EventLog类的用法:提供与 Windows 事件日志的交互。

构造函数: Entries public EventLog (string logName,string machineName):计算机上日志的 名称,日志所在的计算机。

EventLog类属性:Entries。保留事件日志中的项。每个项均与 EventLogEntry 类的一个实例关联。

EventLogEntry类属性:EntryType:该项的事件类型 错误Error或Warning类型EventLogEntryType.Error或EventLogEntryType.Warning Source:获取生成该事件的应用程序的名称

18.您正在创建一个自定义检索值栏目的应用程序配置文件。该自定义栏目使用XML作为显示在下面的块。您需要写一个代码段来定义一个名为Role的类。您需要确保的Role类被初始化的值取自自定义部分配置文件。应该用哪段代码来实现?

纠正翻译:您正在创建一个应用程序,该应用程序从应用程序配置文件的自定义部分中检索值。自定义部分使用

XML,如以下块中所示。

您需要编写一个代码段来定义名为Role 的类。您需要确保用从配置文件的自定义部分中检索的值来初始化Role 类。 您应该使用哪个代码段? A. public class Role :

ConfigurationElement {

internal string _ElementName = \ [ConfigurationProperty(\ public string Name { get {

return ((string)base[\ } } } B. public class Role :

ConfigurationElement {

internal string _ElementName = \

[ConfigurationProperty(\ public string Name { get {

return ((string)base[\ } } } C. public class Role :

ConfigurationElement {

internal string _ElementName = \ private string _name;

[ConfigurationProperty(\ public string Name { get {

return _name; } } } D. public class Role :

ConfigurationElement {

internal string _ElementName = \ private string _name;

[ConfigurationProperty(\ public string Name { get {

return _name; } } } 答案: B

解析:此role类需要继承一个ConfigurationElement类,此类表示表示配置文件中的配置元素。因为我们要取配置文件中的配置元素,所以继承此类是必须的。在类中需定义一个属性确保取值来自配置文件,因为配置文件中的值是 键-值 对的方式,所以按名称来取对应的值。 所以属性的声明中应指明属性的取值范围,是配置文件中键对应的值。这么看应该选B、D中的一个。现在来看到底选哪个。他们两个答案的区别可以从MSDN上看到。

此为查询地址,应选B。

19.您需要生成一个语言代码和地区代码的报告列表。使用哪个代码来实现? A. foreach (CultureInfo culture in CultureInfo.GetCultures(CultureTypes.SpecificCultures)) { // Output the culture information...}

B. CultureInfo culture = new CultureInfo(\ // Output the culture information...

C. foreach (CultureInfo culture in CultureInfo.GetCultures(CultureTypes.NeutralCultures)) { // Output the culture information...}

D. foreach (CultureInfo culture in CultureInfo.GetCultures(CultureTypes.ReplacementCultures)) { // Output the culture information...} 答案: A

解析:第六章 第一小节

主要是是考察的CultureInfo类

其中它的方法GetCultures():获取由指定 CultureTypes 参数筛选的支持的区域性列表。 CultureTypes枚举属性。

CultureTypes.SpecificCultures:某个国家或地区的区域性 CultureTypes.NeutralCultures:非特定区域。所以选A [?nju:tr?l]

20.您创建了一个存储居住在不同区域的客户的信息的应用程序。您是发展中国家的内部工具,用于此应用程序。您需要收集区域信息您的客户在加拿大。您正在为您这个应用程序开发内部的公用程序。您需要收集的客户信息是加拿大国家的客户。用哪段代码可以实现? A. foreach (CultureInfo culture in CultureInfo.GetCultures(CultureTypes.SpecificCultures)) { // Output the region information...}

B. CultureInfo cultureInfo = new CultureInfo(\ C. RegionInfo regionInfo = new RegionInfo(\ D. RegionInfo regionInfo = new RegionInfo(\ { // Output the region information...} 答案: C 第六章 第一小节

答案解析:public RegionInfo (string name)

基于按名称指定的国家/地区或特定区域性初始化 RegionInfo 类的一个新实例。 CultureInfo是按地区名称初始化一个实例

21、您正在开发一个方法,一个字符串中子字符串搜索。 方法将会意大利本地化。 您的方法接受以下参数: 在那个字串中搜索(源串),名为serchList,搜索的子字串,名为searchValue。 您应该使用哪个代码段? A. return searchList.IndexOf(searchValue);

B. CompareInfo comparer = new CultureInfo(\ return comparer.Compare(searchList, searchValue); C. CultureInfo comparer = new CultureInfo(\ if (searchList.IndexOf(searchValue) > 0) {return true;} else {return false;}

D. CompareInfo comparer = new CultureInfo(\ if (comparer.IndexOf(searchList, searchValue) > 0) {return true;} else { return false;}

Answer: D

解析:第六章 第一小节

CompareInfo:实现一组方法进行区分区域性的字符串比较。

要创建CompareInfo的实例,需调用请使用 CultureInfo.CompareInfo 属性,或使用 GetCompareInfo 方法。

IndexOf(source,value)搜索指定的子字符串并返回整个源字符串内第一个匹配项的从零开始的索引。所以选D

22、您正在为在香港居住的客户端开发应用程序。您需要使用一个减号显示负货币值。 您应该使用哪个代码段?

A. NumberFormatInfo culture = new CultureInfo(\ culture.NumberNegativePattern = 1; return numberToPrint.ToString(\ B. NumberFormatInfo culture = new CultureInfo(\ culture.CurrencyNegativePattern = 1; return numberToPrint.ToString(\ C. CultureInfo culture =new CultureInfo(\culture);

D. CultureInfo culture =new CultureInfo(\return numberToPrint.ToString(\culture); Answer: B

解析:第六章 第一小节

此题主要考察NumberFormatInfo:根据区域性定义如何设置数值格式以及如何显示数值。属性:NumberNegativePattern 。获取或设置负数值的格式模式。默认值是1表示-1. [?neɡ?tiv]

属性:CurrencyNegativePattern 获取或设置负货币值的格式模式。 默认值是0 0 ($n) 1 -$n 所以选B

23、您正在为客户开发财政报告。 您的客户都有一个主要的办公室,在美国和一个在墨西哥的卫星办公室。 您需要确保当卫星办公室中的用户生成的该报告 当前日期显示在墨西哥西班牙语格式。 您应该使用哪个代码段?

A. DateTimeFormatInfo dtfi = new CultureInfo(\ DateTime dt = new DateTime(DateTime.Today.Year, DateTime.Today.Month, DateTime.Today.Day);

string dateString = dt.ToString(dtfi.LongDatePattern);

B. Calendar cal = new CultureInfo(\

DateTime dt = new DateTime(DateTime.Today.Year, DateTime.Today.Month, DateTime.Today.Day);

Strong dateString = dt.ToString();

C. string dateString = DateTimeFormatInfo.CurrentInfo GetMonthName(DateTime.Today.Month);

D. string dateString = DateTime.Today.Month.ToString(\ Answer: A 第六章 第一小节

解析:此题主要考察了DateTimeFormatInfo,创建它的新实例,调用CultureInfo的DateTimeFormat属性。

DateTimeFormatInfo:定义如何根据区域性设置 DateTime 值的格式并显示这些值。 24、联系第74道题,解密

您正在开发一个方法,以使用数据加密标准(DES) 算法对敏感数据进行加密。您的方法接受下列参数:

·名为message 的待加密的字节数组 ·名为key 的加密密钥 ·名为iv 的初始化向量

您需要对数据加密。您还需要将加密数据写入MemoryStream 对象。 您应该使用哪个代码段?

A. DES des = new DESCryptoServiceProvider(); des.BlockSize = message.Length;

ICryptoTransform crypto = des.CreateEncryptor(key, iv); MemoryStream cipherStream = new MemoryStream();

CryptoStream cryptoStream = new CryptoStream(cipherStream, crypto, CryptoStreamMode.Write);

cryptoStream.Write(message, 0, message.Length);

D. DES des = new DESCryptoServiceProvider(); //创建一个加密服务对象

ICryptoTransform crypto = des.CreateEncryptor(key, iv); //定义基本的加密转换运算的一个对

MemoryStream cipherStream = new MemoryStream();//创建其支持存储区为内存的流。 CryptoStream cryptoStream = new CryptoStream(cipherStream, crypto, CryptoStreamMode.Write); //定义将数据流链接到加密转换的流。 cryptoStream.Write(message, 0, message.Length); Answer: D

解析:此题主要考察了DES加密。其中

CreateEncryptor()是创建加密器容器,参数是指定的密钥和初始化向量,排除C, CryptoStream:定义将数据流链接到加密转换的流。考察了Write方法,D正确。

25.您正在开发一个调用COM 组件的方法。

您需要使用来显式请求运行库以执行完全堆栈遍历的声明性安全。您必须确保所有调用方在执行您的方法之前都具有要求的COM Interop 信用级别。 您应该为方法设置哪种属性?

A. [SecurityPermission(SecurityAction.Demand, Flags=SecurityPermissionFlag.UnmanagedCode)] B. [SecurityPermission(SecurityAction.LinkDemand, Flags=SecurityPermissionFlag.UnmanagedCode)] C. [SecurityPermission(SecurityAction.Assert, Flags = SecurityPermissionFlag.UnmanagedCode)]

D.[SecurityPermission(SecurityAction.Deny,Flags= SecurityPermissionFlag.UnmanagedCode)] Answer: A

解析:此题考察了SecurityPermission类,Unmanaged:非托管代码

Demand 要求调用堆栈中的所有高级调用方都已被授予了当前权限对象所指定的权限

26.您正在开发一种更高版本验证哈希数据的方法,通过使用 MD5 算法。 数据作为字节数组的命名消息(为message)传递给您的方法。 您需要通过使用 MD5 计算哈希值的传入的参数。 您还需要将结果放入一个字节数组。 您应该使用哪个代码段? A. HashAlgorithm algo = HashAlgorithm.Create(\[??lɡ?rie?m] byte[] hash = algo.ComputeHash(message); //计算哈希值 B. HashAlgorithm algo = HashAlgorithm.Create(\ byte[] hash = BitConverter.GetBytes(algo.GetHashCode());

C. HashAlgorithm algo;algo = HashAlgorithm.Create(message.ToString());byte[] hash = algo.Hash;

D. HashAlgorithm algo = HashAlgorithm.Create(\

byte[] hash = null;algo.TransformBlock(message, 0, message.Length, hash, 0); Answer: A

解析:HashAlgorithm表示所有加密哈希算法实现均必须从中派生的基类。

ComputerHash():计算输入数据的哈希值。题目的数据已经放置到message数组中,所以选A

27.您创建一个通过使用最终用户凭据运行的方法。您需要使用Microsoft Windows 组向用户授权。您必须添加代码段,该代码段确定用户是否在名为Clerk 的本地组中。 您应该使用哪个代码段?

A. WindowsIdentity currentUser = WindowsIdentity.GetCurrent(); foreach (IdentityReference grp in currentUser.Groups)

{NTAccount grpAccount = ((NTAccount)grp.Translate(typeof(NTAccount))); isAuthorized = grpAccount.Value.Equals(Environment.MachineName + @\ if (isAuthorized) break;}

B. WindowsPrincipal currentUser = (WindowsPrincipal)Thread.CurrentPrincipal;

isAuthorized = currentUser.IsInRole(\

C. GenericPrincipal currentUser = (GenericPrincipal) Thread.CurrentPrincipal; isAuthorized = currentUser.IsInRole(\

D. WindowsPrincipal currentUser = (WindowsPrincipal)Thread.CurrentPrincipal;

isAuthorized = currentUser.IsInRole(Environment.MachineName); Answer: B

解析: 此题主要考察的WindowsPrincipal: 允许代码检查 Windows 用户的 Windows 组成员身份。判断这个用户是否在“Clerk”组中。所以选B

28.您正在更改名为MyData.xml 的文件的安全设置。

您需要保留现有的继承访问规则。您还需要避免这些访问规则将来继承更改。 您应该使用哪个代码段?

A. FileSecurity security = new FileSecurity(\ security.SetAccessRuleProtection(true, true); //受保护的审核规则不会通过继承被父对象修改。 File.SetAccessControl(\ B. FileSecurity security = new FileSecurity();

security.SetAccessRuleProtection(true, true);File.SetAccessControl(\ C. FileSecurity security =

File.GetAccessControl(\ D. FileSecurity security = File.GetAccessControl(\ security.SetAuditRuleProtection(true, true); File.SetAccessControl(\Answer: A

解析:此题主要考察了FileSecurity类,表示文件的访问控制和审核安全。方法的SetAcessRuleProtection()方法

最后应设置文件的安全控制,最好的答案选A

29. 您正在编写用于用户身份验证和授权的代码。用户名、密码和角色存储在您的应用程序数据存储区中。您需要建立一个用户安全上下文,用于IsInRole 之类的授权检查。您编写以下代码段以向用户授权。

if (!TestPassword(userName, password))

throw new Exception(\

String[] userRolesArray = LookupUserRoles(userName);

您需要完成此代码,以便它建立用户的安全上下文。 您应该使用哪个代码段?

A. GenericIdentity ident = new GenericIdentity(userName); //该类表示具有指定名称的用户。 GenericPrincipal currentUser = new GenericPrincipal(ident, userRolesArray); //表示当前用户的角色

Thread.CurrentPrincipal = currentUser; //线程当前的负责人是是userRolesArray中userName

B. WindowsIdentity ident = new WindowsIdentity(userName); WindowsPrincipal currentUser = new WindowsPrincipal(ident); Thread.CurrentPrincipal = currentUser;

C. NTAccount userNTName = new NTAccount(userName); GenericIdentity ident = new GenericIdentity(userNTName.Value);

GenericPrincipal currentUser= new GenericPrincipal(ident, userRolesArray); Thread.CurrentPrincipal = currentUser;

D. IntPtr token = IntPtr.Zero;token = LogonUserUsingInterop(userName, encryptedPassword); WindowsImpersonationContext ctx = WindowsIdentity.Impersonate(token); Answer: A

解析:对比几个答案,A最满足题意

30、您正在将一个新程序集加载到应用程序中。您需要替代程序集的默认证据。您需要用公共语言运行库(CLR) 向程序集授予权限集,从本地Intranet 区域中加载程序集。 您需要建立证据集。 您应该使用哪个代码段?

A. Evidence evidence = new Evidence(Assembly.GetExecutingAssembly().Evidence ); B. Evidence evidence = new Evidence();

evidence.AddAssembly(new Zone(SecurityZone.Intranet)); //将指定的程序集证据添加到证据

集。

C. Evidence evidence = new Evidence();

evidence.AddHost(new Zone(SecurityZone.Intranet)); //将主机提供的指定证据添加到证据集。 D. Evidence evidence = new Evidence(AppDomain.CurrentDomain.Evidence); Answer: C

解析: 关键是就好像从本地Intranet 区域中加载程序集一样这一句,遍历所有答案,只有C完成了一个功能,所以答案选C

31.您正在开发一个类库,将打开网络套接字到网络上的计算机的连接。

您会将该类库部署到全局程序集缓存并授予它完全信任。 您编写以下代码,确保使用的套接字连接。

SocketPermission permission =new SocketPermission(PermissionState.Unrestricted); permission.Assert();//您的代码有权限执行、但代码的调用方可能没有权限执行的操作, 警告 请谨慎使用断言,因为它们会打开安全漏洞,并会破坏运行库实施安全限制的机制。

某些使用类库的应用程序可能没有必需的权限以打开网络套接字连接。 您需要取消该断言。 您应该使用哪个代码段? A. CodeAccessPermission.RevertAssert(); B. CodeAccessPermission.RevertDeny(); C. permission.Deny();

D. permission.PermitOnly(); Answer: A

解析:此题考察的是用户权限问题

CodeAccessPermission:定义所有代码访问权限的基础结构

RevertAssert():导致当前框架先前的所有 Assert 都被移除,不再有效,以保证程序的安全

所以选A;

32.您正在开发的应用程序将使用自定义身份验证和基于角色的安全性。 您需要编写要运行库将一个未经身份验证的主体对象分配给每个运行的线程的代码段。 您应该使用哪个代码段?

A. AppDomain domain = AppDomain.CurrentDomain; domain.SetPrincipalPolicy(PrincipalPolicy.WindowsPrincipal); B. AppDomain domain = AppDomain.CurrentDomain; domain.SetThreadPrincipal(new WindowsPrincipal(null)); C. AppDomain domain = AppDomain.CurrentDomain; domain.SetAppDomainPolicy(PolicyLevel.CreateAppDomainLevel()); D. AppDomain domain = AppDomain.CurrentDomain;

domain.SetPrincipalPolicy(PrincipalPolicy.UnauthenticatedPrincipal); Answer: D

解析; 此题目考察的是PrincipalPolicy.类。指定应该如何为应用程序域创建用户和标识对象。默认为 UnauthenticatedPrincipal。 未经身份验证的主体对象 有三个值:

NoPrincipal 不应该创建任何用户或标识对象。

UnauthenticatedPrincipal 应该为未经身份验证的实体创建用户和标识对象。未经身份验证的实体的 Name 设置为空字符串 (\,IsAuthenticated 设置为 false。

WindowsPrincipal 应该创建反映与当前执行线程相关的操作系统标记的用户和标识对象 从题目来看是未经身份验证的用户,所以只有D答案正确。 33.Drag Drop question.Drag拖放问题。

拖动并将问题。 将项拖到适当的位置。 Answer:

34.您在开发应用程序执行数学计算。 您开发一个名为 CalculationValues 的类。 您编写一个名为 PerformCalculation 在 类的实例上运行的过程。 您需要确保应用程序的用户界面继续执行计算时作出回应。 您需要编写一个调用PerformCalculation来达到这个目的代码段。

您会使用哪一个代码段?

A. private void PerformCalculation() {...} private void DoWork()

{ CalculationValues myValues = new CalculationValues();

Thread newThread = new Thread( new ThreadStart(PerformCalculation)); newThread.Start(myValues);}

B. private void PerformCalculation() {...}

private void DoWork()

{ CalculationValues myValues = new CalculationValues(); ThreadStart delStart = new ThreadStart(PerformCalculation); Thread newThread = new Thread(delStart);

if (newThread.IsAlive) {newThread.Start(myValues);}} D. private void PerformCalculation(object values) {...} private void DoWork()

{ CalculationValues myValues = new CalculationValues(); Thread newThread = new Thread( new ParameterizedThreadStart(PerformCalculation));

newThread.Start(myValues);} //这个方法在Calculation实例上运行 Answer: D

解析: 考察的是创建多线程以及启动一个线程的方法Start()方法,以及方法的重载Start(object).

因为此线程在一个类的实例中运行。所以这个方法,必须有参数,参数是一个对象,包含线程执行的方法要使用的数据。排除A,B

创建一个线程在创建托管的线程时,在该线程上执行的方法将通过一个传递给 Thread 构造函数的 ThreadStart 委托或 ParameterizedThreadStart 委托来表示。 例如: Thread newThread = new Thread(new ThreadStart(Calculator));

对比答案C 、D。以及题目要求在后台执行计算,前台继续得到响应。所以应选择多线程。 35.纠正翻译:

您开发一个需要部署的服务应用程序。 您的网络管理员为您的服务应用程序创建特定的用户帐户。 您需要配置您的服务应用程序在此特定用户帐户的上下文中运行。 您怎么办? 纠正翻译:

A. 在安装之前,设置ServiceInstaller 类的StartType 属性。 B. 在安装之前,设置ServiceProcessInstaller 类的Account、Username 和Password 属性。 C. 使用net.exe 命令行工具的CONFIG 选项来安装服务。 D. 使用installutil.exe 命令行工具来安装服务。

解析:此题考查的是安装一个可执行文件.ServiceProcessInstaller类

在安装服务应用程序时由安装实用工具(installutil.exe)来调用,要设定用户名和密码,所以答案选B Answer: B

36.纠正翻译:您正在编写一个方法,该方法返回名为al 的ArrayList。您需要确保以线程安全的方式对ArrayList 执行更改。 您应该使用哪个代码段?

A. ArrayList al = new ArrayList();lock (al.SyncRoot){ return al;}

B. ArrayList al = new ArrayList();lock (al.SyncRoot.GetType()){ return al;} C. ArrayList al = new ArrayList();Monitor.Enter(al);Monitor.Exit(al);return al; D. ArrayList al = new ArrayList();

ArrayList sync_al = ArrayList.Synchronized(al); return sync_al; Answer: D

解析:此题考察的是线程安全,Synchronized方法的使用。返回同步的(线程安全)ArrayList 包装。 所以选D

37. 纠正翻译:您需要编写一个代码段中,该代码段将在应用程序内创建公共语言运行库(CLR) 隔离单元。您应该使用哪个代码段?

A. AppDomainSetup mySetup = AppDomain.CurrentDomain.SetupInformation; mySetup.ShadowCopyFiles = \ B. System.Diagnostics.Process myProcess; myProcess = new System.Diagnostics.Process(); C. AppDomain domain;

domain = AppDomain.CreateDomain(\//创建一个新的域 D. System.ComponentModel.Component myComponent;myComponent = new System.ComponentModel.Component(); Answer: C

解析: 此题考察的是AppDomain。表示应用程序域,它是一个应用程序在其中执行的独立环

境(这里指CLR)。CreateDomain():方法创建一个新的程序域。所以答案选C

38. 您创建一个类库包含在下面的代码段中定义的类层次结构。 (行号将包括只供参考)。

您创建组类的实例。 您填充实例的字段。 当尝试通过使用 Serialize 方法 XmlSerializer 类的序列化该实例会收到 InvalidOperationException。 您还会收到以下错误消息。 \出错生成 XML 文档\。

您需要修改代码段,以使您可以成功地序列化组类的实例,这可以通过使用 XmlSerializer 类。 您还需要确保 XML 输出中包含类的层次结构中的所有公共字段的一个元素。 您怎么办?

A. Insert the following code between lines 1 and 2 of the code segment: [XmlArrayItem(Type = typeof(Employee))] [XmlArrayItem(Type = typeof(Manager))]

B. Insert the following code between lines 1 and 2 of the code segment: [XmlElement(Type = typeof(Employees))]

C. Insert the following code between lines 1 and 2 of the code segment: [XmlArray(ElementName=\

D. Insert the following code between lines 3 and 4 of the code segment: [XmlElement(Type = typeof(Employee))] andInsert the following code between lines 6 and 7 of the code segment: [XmlElement(Type = typeof(Manager))] Answer: A 39.重新翻译:

您正在定义一个名为MyClass 的类,它包含若干个子对象。MyClass 包含一个名为ProcessChildren的方法,该方法对子对象执行操作。 MyClass 对象将是可序列化的对象。

您需要确保在重建MyClass 对象及其所有子对象之后执行ProcessChildren 方法。

您应该执行哪两项操作?(每个正确答案都仅给出了部分解决方案。请选择两个答案。) A. 将OnDeserializing 属性应用于ProcessChildren 方法。 B. 指定MyClass 实现IDeserializationCallback 接口。 C. 指定MyClass 从ObjectManager 类继承。

D. 将OnSerialized 属性应用于ProcessChildren 方法。 E. 创建一个调用ProcessChildren 的GetObjectData 方法。 F. 创建一个调用ProcessChildren 的OnDeserialization 方法。 Answer: BF

解析: 此题要求MyClass对象可序列化,所以应该继承IDeserializationCallback接口所以B; OnDeserialization 方法。并在完成反序列化后由反序列化事件回调。所以选F Serialized assemlbly

40. 纠正翻译:

您需要以字符串形式返回独立存储文件的内容。该文件在计算机范围内,名为Settings.dat。您应该使用哪个代码段?

解析:该文件在计算机范围内,排除AC,以字符串形式返回,需要用StreamReader,所以选B

A. IsolatedStorageFileStream isoStream;

isoStream = new IsolatedStorageFileStream(\ string result = new StreamReader(isoStream).ReadToEnd();

B. IsolatedStorageFile isoFile;isoFile = IsolatedStorageFile.GetMachineStoreForAssembly(); IsolatedStorageFileStream isoStream;

isoStream = new IsolatedStorageFileStream(\ string result = new StreamReader(isoStream).ReadToEnd(); C. IsolatedStorageFileStream isoStream;

isoStream=new IsolatedStorageFileStream(\ string result = isoStream.ToString(); D. IsolatedStorageFile isoFile;

isoFile = IsolatedStorageFile.GetMachineStoreForAssembly(); IsolatedStorageFileStream isoStream;

isoStream = new IsolatedStorageFileStream(\ string result = isoStream.ToString(); Answer: B

解析:此题目考察了IsolatedStorageFileStream,独立存储的文件流。 StreamReader()流的方法读字符串并返回。所以排除C,D 考虑 A、B题目:该文件在计算机范围内

所以调用GetMachineStoreForAssembly()获取与调用代码的应用程序标识对应的计算机范围的独立存储。

41.您使用SOAP写一个应用程序与另一个应用程序交互数据。您使用一个Department类继承ArrayList发送对象到另一个应用程序。Department类的对象名为dept。您需要运用SOAP来保证该应用程序连续的传送Department类的对象。下列哪段代码是您所需要的? A. SoapFormatter formatter = new SoapFormatter(); byte[] buffer = new byte[dept.Capacity];

MemoryStream stream = new MemoryStream(buffer); foreach (object o in dept) { formatter.Serialize(stream, o);} B. SoapFormatter formatter = new SoapFormatter(); byte[] buffer = new byte[dept.Capacity];

MemoryStream stream = new MemoryStream(buffer); formatter.Serialize(stream, dept);

C. SoapFormatter formatter = new SoapFormatter(); MemoryStream stream = new MemoryStream();

foreach (object o in dept) { formatter.Serialize(stream, o);} D. SoapFormatter formatter = new SoapFormatter(); MemoryStream stream = new MemoryStream(); formatter.Serialize(stream, dept); Answer: D

解析:要发送的对象名是dept,所以排除AC,写法不对。Dept的大小是随时变化的,所以排除B ,答案选D. SOAP是用来向第二个应用程序传递信息

42.(纠正翻译)您正在测试一个组件,该组件对Meeting 类实例进行序列化处理,以使它们能够保存到文件系统。 Meeting 类具有以下定义: public class Meeting { private string title;

public int roomNumber; public string[] invitees; public Meeting(){ }

public Meeting(string t){ title = t; } }

组件包含一个带有以下代码段的过程。

Meeting myMeeting = new Meeting(\myMeeting.roomNumber=1100;

string[] attendees = new string[2]{\

myMeeting.invitees = attendees;

XmlSerializer xs = new XmlSerializer(typeof(Meeting));

StreamWriter writer = new StreamWriter(@\xs.Serialize(writer, myMeeting); writer.Close();

您需要确定作为运行此过程的结果写入C:\\Meeting.xml 文件的XML 块。 哪个XML 块代表将写入C:\\Meeting.xml 文件的内容? A.

Goals

1100 John Mary

B.

1100

John Mary

C.

1100

John Mary

D.

1100

title=\

John Mary Answer: B

43. 纠正翻译:

您正在编写一个使用独立存储来存储用户首选项的应用程序。该应用程序使用多个程序集。多位用户将在同一台计算机上使用此应用程序。

您需要在仅供当前Microsoft Windows 标识和程序集所使用的独立存储区域中创建名为Preferences 的目录。 当前的用户的程集内建立Preferences的目录 您应该使用哪个代码段?

A. IsolatedStorageFile store;store = IsolatedStorageFile.GetUserStoreForAssembly(); store.CreateDirectory(\ B. IsolatedStorageFile store;

store = IsolatedStorageFile.GetMachineStoreForAssembly(); store.CreateDirectory(\ C. IsolatedStorageFile store;

store = IsolatedStorageFile.GetUserStoreForDomain(); store.CreateDirectory(\ D. IsolatedStorageFile store;

store = IsolatedStorageFile.GetMachineStoreForApplication(); store.CreateDirectory(\ Answer: A

解析:本题考查的是:独立存储程序集中,创建Preferences目录。

GetUserStoreForAssembly()是用户的独立存储程序集中创建标识。所以答案选A

44. //纠正翻译:

您需要编写代码段,用于将名为stream1 的流变量的前80 个字节传输到名为byteArray 的新字节数组中。您还需要确保代码段将传输的字节数赋值到名为byteTransferred 的整型变量中。您应该使用哪个代码段?

您需要写一个代码段去传递开始的80个字节从一个流变量名为stream1进入到一个新的字节数组名为byteArray内。您同样保证代码段能分配一定数量的字节转化到一个整数变量名

为bytesTransferred。您需要用下列哪个代码段? A. bytesTransferred = stream1.Read(byteArray, 0, 80); B. for (int i = 0; i < 80; i++)

{ stream1.WriteByte(byteArray[i]); bytesTransferred = i; if (!stream1.CanWrite) { break; }}

C. while (bytesTransferred < 80)

{ stream1.Seek(1, SeekOrigin.Current);

byteArray[bytesTransferred++] = Convert.ToByte(stream1.ReadByte());} D. stream1.Write(byteArray, 0, 80); bytesTransferred = byteArray.Length; Answer: A

解析:主要考察的是将传输的字节数赋值到一个整型变量中。Read方法返回一个整型变量,所以选A

45. 您写一个方法去接受一个字符串参数指定的消息。您的方法必须暂停消息参数进入到单独的排列文本和传递各自排列在第二个方法中,方法名为Process。下列哪个代码段是您需要的?

A. StringReader reader = new StringReader(message); Process(reader.ReadToEnd()); reader.Close();

B. StringReader reader = new StringReader(message);

while (reader.Peek() != -1) { string line = reader.Read().ToString(); Process(line);} reader.Close();

C. StringReader reader = new StringReader(message); Process(reader.ToString()); reader.Close();

D. StringReader reader = new StringReader(message); while (reader.Peek() != -1) { Process(reader.ReadLine());} reader.Close(); Answer: D

解析:在读消息时,应该判断是否还有下一个字符,在B。D中选择,读取一行是ReadLine()

方法,所以选D

46. //您开发一个应用程序用于完成精确的运算。您需要保证该应用程序尽可能的完成同步复杂的计算。您将如何去做? 纠正翻译

A. 设置ProcessThread 对象的IdealProcessor 属性。 B. 设置ProcessThread 对象的ProcessorAffinity 属性。

C. 为每个计算调用ThreadPool 类的QueueUserWorkItem 方法。 D. 将Process.GetCurrentProcess().BasePriority 属性设置为High。

Answer: C

解析:看题目要求,需要同步完成复杂的计算,所以需要一个多线程的操作。A答案,设置让此线程在其上运行的首选处理器。因为是同时完成,所以首选肯定不可以。B答案,设置关联线程可以在其上运行的处理器。线程的处理器关联是线程与其有关系的一组处理器。也就是可安排该线程在其上运行的那些处理器。答案C,使用这个方法将把所有的方法异步委托排列到池里去,异步实现这才是我们要的结果,所以答案C是正确的。D答案,是设置优级为高,而咱们的要求是同步完成,所以不符合要求。

47. //您开发一个服务应用程序名为PollingService能周期性的调用长时间运行的程序。这些程序被称为DoWork方法。您运用服务应用程序代码。

//当您尝试开始服务,您收到错误报文。不能开始PollingService服务在本地电脑,错误1053:服务开启没有被响应或在短时间内控件请求。您需要修改服务应用程序代码因此服务完全开启。您将如何去做?

A. 从onStart方法中循环移动代码到构造函数中。

B. //拖一个计时器组件到设计界面的拖盘中,从Onstart方法中移动调用已经运行的存储过

程到Tick事件中,设置计时器组件的可用属性为true,并且在onStart方法中调用计时器的开始方法。

C. /添加一个类级别System.Timers.Timer变量服务类代码。移动调用DoWork方法到经过事

件过程中的计时器,请将Enabled属性设置的定时器为True ,并在OnStart方法中调用计时器的Start方法。

D. //移动循环代码从OnStart方法到DoWork方法

Answer: C

解析:每个答案的翻译都在上边,可以从中排除A和D,看B和C的区别,一个是把存储过程调到tick事件中,一个是调DoWork方法到计时器中。而最根本的要点就是这个doWork方法在持续运行。所以应该选C。

48. 正确翻译:

您开发一个名为FileService 的服务应用程序。您将该服务应用程序部署到网络上的多台服务器。

您执行以下代码段。(包括的行号仅供参考。) 01 public void StartService(string serverName){ 02 ServiceController crtl = new

03 ServiceController(\

04 if (crtl.Status == ServiceControllerStatus.Stopped){ 05 } 06 }

您需要开发一个例程,如果FileService 停止,该例程将启动它。该例程必须在由serverName 输入参数确定的服务器上启动FileService。 您应该将哪两行代码添加到代码段?(每个正确答案都仅给出了部分解决方案。请选择两个答案。)

Servername是指机器的名字

A. 在03 行和04 行之间插入以下代码行: crtl.ServiceName = serverName;

B. 在03 行和04 行之间插入以下代码行: crtl.MachineName = serverName;

C. 在03 行和04 行之间插入以下代码行: crtl.Site.Name = serverName;

D. 在04 行和05 行之间插入以下代码行: crtl.Continue();

E. 在04 行和05 行之间插入以下代码行: crtl.Start();

F. 在04 行和05 行之间插入以下代码行: crtl.ExecuteCommand(0); Answer: BE

解析:B,E,原因,题目要求,在服务器识别时,程序利用服务器名输入参数来开启FileService。所以需要传入服务器名字,所以肯定是MachineName=ServerName正确,而E的原因是因为服务是停止的,所以需要启动服务,用Start()方法。

49. 您在开发一个应用程序,从一个应用程序目录中动态的加载程序集。您需要写一段程序代码去加载名为Assembly1.dll的程序集在当前的应用程序范围内。您将如何运用下列的代

码段?

A. AppDomain domain = AppDomain.CurrentDomain;

string myPath = Path.Combine(domain.BaseDirectory, \ Assembly asm = Assembly.LoadFrom(myPath); //从这个应用程序目录中加载程序集 B. AppDomain domain = AppDomain.CurrentDomain;

string myPath = Path.Combine(domain.BaseDirectory, \ Assembly asm = Assembly.Load(myPath);

C. AppDomain domain = AppDomain.CurrentDomain;

string myPath = Path.Combine(domain.DynamicDirectory, \ Assembly asm = AppDomain.CurrentDomain.Load(myPath); D. AppDomain domain = AppDomain.CurrentDomain; Assembly asm = domain.GetData(\ Answer: A

解析:应用程序域,可以被看作一个轻型的进程。在一个 Win32 进程中可以存在多个 appdomain。appdomain 的主要目的是将应用程序和其它应用程序隔离开来。CurrentDomain属性是获取当前线程的当前应用程序域,而BaseDirectory是获取基目录,它由程序集冲突解决程序用来探测程序集。而加载程序集的LoadFrom方法的参数是字符串,功能是加载程序集清单的文件的名称或路径。 而Load方法的参数也是字符串,功能是加载程序集名称的长格式。看答案其实A和B都说得过去,但是如果用一个最佳答案的话,A最佳。

50. //您的应用程序运用了两个线程,名分别为threadOne和threadTwo.您需要修改代码防止从线程threadOne的执行到threadTwo的执行完成。您将如何去做?

A. 将threadOne 配置为以较低优先级运行。 B. 将threadTwo 配置为以较高优先级运行。 C. 使用WaitCallback 委托同步这两个线程。 D. 调用threadOne 的Sleep 方法。 E. 调用threadOne 的SpinLock 方法。 Answer: C

解析:显示A,B,D都不合适。A,B不管优先级为什么,都早晚会执行完毕,题目要求是不允许执行完成,所以AB都不正确 ,D是睡眠,肯定也不合适,睡眠结束之后还是要运行,看C和E,C是等待程序去回调,如果你不回调,就会一直不运行,看来C可以,再看E,SpinLock功能是,是一种 Linux 内核中广泛运用的底层同步机制。是一种工作于多处理器环境的特殊的锁,在单处理环境中自旋锁的操作被替换为空操作。所以,E也不合适。

51.您正在调试一个应该程序, 您需要找到抛出异常的代码。异常类的哪一个属性能完成这一目的。 A. Data B. Message C. StackTrace D. Source Answer: C

解析:此程序是没有什么悬念的,data是数据,Message是消息。Source是数据源,所以只能选择C。栈跟踪

52.您需要写一个接收日期参数的多播委托,您应该使用哪一个代码片段 //委托就是一个方法,题目没有返回值

A. public delegate int PowerDeviceOn(bool result, DateTime autoPowerOff); B. public delegate bool PowerDeviceOn(object sender, EventArgs autoPowerOff); C. public delegate void PowerDeviceOn(DateTime autoPowerOff); D. public delegate bool PowerDeviceOn(DateTime autoPowerOff); Answer: C

解析:多播委托可以有返回值,但是本题中没要求有返回值,所以答案为C。

53. 您正在创建一个撤消缓冲区存储数据的修改 您首先必须确保撤消功能复原大部分最近修改的数据 您还需要确保撤消缓冲区,只允许存储字符串。 您应该使用哪一个代码段?

A. Stack undoBuffer = new Stack(); B. Stack undoBuffer = new Stack();

C. Queue undoBuffer = new Queue(); D. Queue undoBuffer = new Queue(); Answer: A

解析:缓冲区是堆栈部分,所以要撤消缓冲区的数据修改,需要把缓冲区重新new出来,而且是只允许存储字符串,所以应为string泛型类。 54.

您正在创建一个使用非托管资源的类, 这个类保持在其它对象上的有管理代码

您应该确保这个类的使用者能在这个类不再使用时释放资源 您应该执行哪三个动作? (每一个正确的答案提出解决办法的一部分 ,选择三个.)

答案翻译:A. 定义类使得该类继承于WeakReference 类。 B. 定义类使得该类实现IDisposable 接口。

C. 创建类析构函数,该函数在其他对象上调用方法来释放托管资源。 D. 创建一个释放非托管资源的类析构函数。

E. 创建一个Dispose 方法,该方法调用System.GC.Collect 来强制进行垃圾回收。

F. 创建一个Dispose 方法,该方法释放非托管资源,并在其他对象上调用方法来释放托管资源。

Answer: B, D, F

解析:实现需要有三步,第一步,需要声明一个类,实现IDisposable接口的方法。 第二步,创建一个类的析构函数释放非托管资源。

第三步,创建一个Dispose方法时释放非托管资源,并调用其他对象上的方法释放管理资源。 这三步对应BDF选项。 55.

您需要创建一个方法,清除命名为q的Queue,您应该使用哪一个代码片段? A. foreach (object e in q) { q.Dequeue();} B. foreach (object e in q) { Enqueue(null);} C. q.Clear(); D. q.Dequeue(); Answer: C

解析:集合和队列的清除全是用clear方法。所以选C。

56.您写了下面这段代码

public delegate void FaxDocs(object sender, FaxArgs args); 您需要创建一个事件去调用FaxDocs,您应该使用哪个代码片段 A. public static event FaxDocs Fax; event声明事件的关键字。 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;} }} Answer: A

解析:C和D肯定是错误的,声明了委托,需要用委托作为数据类型去声明事件,所以A和B中的一个是正确的。A是声明的委托类型,B是Fax类型的。是错误的。所以选A。

57. 您应该选择一个类,是从小的和大的集合中恢复关键项的最好的。 您应该选择哪一个类?

A. OrderedDictionary class 表示根据键/索引排序的键/值对的集合。 B. HybridDictionary class C. ListDictionary class 小集合。

D. Hashtable class 存储大集合时效率最高。 Answer: B

解析:看每一个类的解释,应该选用B,当集合数目大于10,小于10时,有所区别

58. 正确翻译:您正在创建一个名为Assembly1 的强名称程序集,该程序集将在多个应用程序中使用。在开发周期中, 将会频繁重新建立Assembly1。您需要确保该程序集在每次重新建立时都能与使用它的每个应用程序正常协同工作。

您需要配置在其中开发Assembly1 的计算机,以使每个应用程序都使用Assembly1 的最新版本。

您应该执行哪两项操作?(每个正确答案都仅给出了部分解决方案。请选择两个答案。) A. 创建一个DEVPATH 环境变量,该环境变量指向强名称程序集的版本输出目录。 B. 将以下XML 元素添加到计算机配置文件:

D. 将以下XML 元素添加到使用强名称程序集的每个应用程序的配置文件:

E. 将以下XML 元素添加到使用强名称程序集的每个应用程序的配置文件:

language=\ Answer: AB

59.您正在使用Microsoft Visual Studio 2005 IDE 检查一个返回string的方法的输出信息,您指定这个方法的输出给一个命名为fName的变量,您需要写一个代码片段打印下面这一行信息\如果fName的值不为”John”,您应该确定这个应该程序的代码持续的执行,您应该使用哪一个代码片段

A. Debug.Assert(fName == \ B. Debug.WriteLineIf(fName != \

C. if (fName != \{ Debug.Print(\FaileD. \ Debug.Print(fName); }

D. if (fName != \{ Debug.WriteLine(\FaileD. \ Debug.WriteLine(fName); } Answer: B

60. 正确翻译:您创建一个由公司三个部门中的应用程序使用的类库。该库包含一个具有以下定义的Department 类。 public class Department { public string name; public string manager; }

每个应用程序使用一个自定义配置节在应用程序配置文件中存储特定于部门的值,如以下代码中所示。

Hardware Amy

您需要编写一个代码段,该代码段通过使用从应用程序配置文件中检索的字段值来创建Department 对象实例。 您应该使用哪个代码段?

C. public class deptHandler :IConfigurationSectionHandler { public object Create(object parent, object configContext, System.Xml.XmlNode section) {

Department dept = new Department();

dept.name = section.SelectSingleNode(\

dept.manager =

section.SelectSingleNode(\return dept; } }

D. public class deptHandler :IConfigurationSectionHandler { public object Create(object parent, object configContext, System.Xml.XmlNode section) {

Department dept = new Department();

dept.name = section.Attributes[\

dept.manager = section.Attributes[\return dept; } }

Answer: C

解析:从题目中看需要返回一个对象值,所以必须要声明一个有返回值且返回值类型为对象类型的方法,可以排除答案A和B。C和D的区别就在于使用section的哪个方法来取得值了。从MSDN上可以看到,XMLNode就没有Attributes[“name”]的用法。所以应选C。SelectSingleNode方法的功能,选择匹配 XPath 表达式的第一个 XmlNode。

61.您测试名为PersistToDB的一个新开发的方法。 这个方法接受类型EventLogEntry的参数

。 这个方法不返回值。 您需要编写一段代码帮助您来测试这个方法。 代码段必须从本地计算机应用程序中读词条并且通过PersistToDB方法传递词条。代码块必须通过事件类型错误或警告从源MySource到PersistToDB方法。 您应该使用哪个代码段?

A. EventLog myLog = new EventLog(\ foreach (EventLogEntry entry in myLog.Entries) { if (entry.Source == \ } B. EventLog myLog = new EventLog(\ myLog.Source = \

foreach (EventLogEntry entry in myLog.Entries)

{ if (entry.EntryType == (EventLogEntryType.Error & EventLogEntryType.Warning)) { PersistToDB(entry); } }

C. EventLog myLog = new EventLog(\ foreach (EventLogEntry entry in myLog.Entries) { if (entry.Source == \

{if (entry.EntryType == EventLogEntryType.Error | entry.EntryType == EventLogEntryType.Warning)

{ PersistToDB(entry); } } } D. EventLog myLog = new EventLog(\ myLog.Source = \

foreach (EventLogEntry entry in myLog.Entries)

{if (entry.EntryType == EventLogEntryType.Error |entry.EntryType == EventLogEntryType.Warning) {PersistToDB(entry); } 答案: C

62.您正在开发的应用程序接收异步事件。您创建一个WqlEventQuery实例指向 特定的事件和事件条件,该申请必须作出反应。您也创建了ManagementEventWatcher实例为了订阅查询相匹配的事件。您需要确定的其他行动之前,您必须执行的应用程序可以接收异步事件。这两项行动应

您执行? (每正确回答提出解决办法的一部分。请选择两项。 )

A. 通过调用Start方法的ManagementEventWatcher开始监听事件 B. 为事件设置一个监听者使用ManagementEventWatcher的EventArrived 事件 C. 使用ManagementEventWatcher事件的WaitForNextEvent 方法等待这个事件 D. 建立一个事件句柄类,其中的方法用来接收ObjectReadyEventArgs 传递的参数 E.为事件设置一个监听者用ManagementEventWatcher来停止事件 答案: A, B

63.您要测试的方法,检查运行过程。此方法返回一个被加载在C:\\TestApps\\Process1.exe进程中包含名称和全路径的所有模块的ArrayList,。您需要加载的模块列表中的进程,您用下面的哪个代码?

A. ArrayList ar = new ArrayList(); Process[] procs;

ProcessModuleCollection modules; procs = Process.GetProcesses(@\

if (procs.Length > 0) {modules = procs[0].Modules;

foreach (ProcessModule mod in modules) {ar.Add(mod.ModuleName); }}

B. ArrayList ar = new ArrayList(); Process[] procs;

ProcessModuleCollection modules;

procs = Process.GetProcesses(@\ if (procs.Length > 0) { modules = procs[0].Modules;

foreach (ProcessModule mod in modules) {ar.Add(mod.ModuleName); }} C. ArrayList ar = new ArrayList(); Process[] procs;

ProcessModuleCollection modules;

procs = Process.GetProcessesByName(@\ if (procs.Length > 0) { modules = procs[0].Modules;

foreach (ProcessModule mod in modules) {ar.Add(mod.FileName); }} D. ArrayList ar = new ArrayList(); Process[] procs;

ProcessModuleCollection modules;

procs = Process.GetProcessesByName(@\ if (procs.Length > 0) { modules = procs[0].Modules;

foreach (ProcessModule mod in modules) {ar.Add(mod.FileName); }} 答案: C

解析:题目考察的是得到指定进程的进程资源,所以选择GetProcessesByName(). 排除答案AB。D的路径名写错了。所以选C

64. 您创建了一个应用程序,存储信息为您的居住在不同区域的客户。在您的应用程序中的作用是发展中的国家的工具。您需要收集您位于加拿大的客户的区域信息,该段代码应该如何使用:?

A. foreach (CultureInfo culture in CultureInfo.GetCultures(CultureTypes.SpecificCultures)) { // Output the region information...}

B. CultureInfo cultureInfo = new CultureInfo(\ C. RegionInfo regionInfo = new RegionInfo(\ D. RegionInfo regionInfo = new RegionInfo(\ { // Output the region information...} 答案: C

65.您正在为一个客户进行财务报表。您的客户在美国墨西哥办事处有一个主要的办公室。您必须确保当用户在办公室产生的报告,当前的日期显示在墨西哥西班牙语格式。该代码段应该使用?

A. DateTimeFormatInfo dtfi = new CultureInfo(\ DateTime dt = new DateTime(DateTime.Today.Year, DateTime.Today.Month, DateTime.Today.Day);

string dateString = dt.ToString(dtfi.LongDatePattern); B. Calendar cal = new CultureInfo(\

本文来源:https://www.bwwdw.com/article/bh83.html

Top