




已阅读5页,还剩21页未读, 继续免费阅读
版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领
文档简介
1、 您为业务合作伙伴创建一个用于提交采购订单的应用程序。该应用程序将合作伙伴发送的XML文档反序列化为名为PurchaseOrder的实例。您需要修改该应用程序,以便在反序列化过程中遇到未能映射到PurchaseOrder对象的公共成员的任何XML内容时,该应用程序能够收集相关详细信息。您应该如何操作?A. 向PurchaseOrder类定义应用XmlIgnore属性。B. 定义一个继承自XmlSerializer且重写XmlSerialize.FromMappings方法的类。C. 向PurchaseOrder类定义应用XmlInclude属性。D. 为XmlSeriallizer.UnknownNode事件定义并实现事件处理程序。Answer:D2、您正在编写一个压缩字节数组的方法。将在名为document的参数中将要压缩的字节传递到此方法。您需要压缩传入参数的内容。您应该使用哪个代码段?A.MemoryStream inStream = new MemoryStream(document);GZipStream zipStream = new GZipStream(inStream, CompressionMode.Compress);byte result = new bytedocument.Length;zipStream.Write(result, 0, result.Length);return result;B.MemoryStream inStream = new MemoryStream(document);GZipStream zipStream = new GZipStream(inStream, CompressionMode.Compress);MemoryStream outStream = new MemoryStream();int b;while (b = zipStream.ReadByte() != -1) outStream.WriteByte(byte)b);return outStream.ToArray();C.MemoryStream stream = new MemoryStream(document);GZipStream zipStream = new GZipStream(stream, CompressionMode.Compress);zipStream.Write(document, 0, document.Length);zipStream.Close();return stream.ToArray();D.MemoryStream outStream = new MemoryStream();GZipStream zipStream = new GZipStream(outStream, CompressionMode.Compress);zipStream.Write(document, 0, document.Length);zipStream.Close();return outStream.ToArray();3、您需要将名为Message.txt的文件的全部内容读取到单个字符串变量中。您应该使用哪个代码段?A.string result = string.Empty;StreamReader reader = new StreamReader(Message.txt); while(!reader.EndOfStream)result += reader.ToString();B.string result = null;StreamReader reader = new StreamReader(Message.txt); result = reader.ReadLine();C.string result = null;StreamReader reader = new StreamReader(Message.txt); result = reader.ReadToEnd();D.string result = null;StreamReader reader = new StreamReader(Message.txt); result = reader.Read().ToString();4、您开发一个可将文本附加到现有文本文件的应用程序。您需要编写一个代码段,该代码段允许应用程序将文本附加到一个名为c:MyFile.txt的文件中。该应用程序必须在文件不存在时引发异常。您需要确保其他应用程序能够读取但不能够修改该文件。您应该使用哪个代码段?A.FileStream fs = new FileStream(C:MyFile.txt,FileMode.Append, FileAccess.ReadWrite);B.FileStream fs = new FileStream(C:MyFile.txt,FileMode.Open, FileAccess.ReadWrite, FileShare.Read);C.FileStream fs = new FileStream(C:MyFile.txt,FileMode.OpenOrCreate, FileAccess.ReadWrite,FileShare.Read);D.FileStream fs = new FileStream(C:MyFile.txt,FileMode.Open, FileAccess.Read, FileShare.ReadWrite);5、您需要以二进制格式序列化List类型的对象。该对象名为data.您应该使用哪个代码段?A、BinaryFormatter formatter = new BinaryFormatter(); MemoryStream stream = new MemoryStream(); data.ForEach(delegate(int num) formatter.Serialize(stream, num); );B、BinaryFormatter formatter = new BinaryFormatter(); MemoryStream stream = new MemoryStream(); formatter.Serialize(stream, data);C、BinaryFormatter formatter = new BinaryFormatter(); byte buffer = new bytedata.Count; MemoryStream stream = new MemoryStream(); formatter.Serialize(stream, data);D、BinaryFormatter formatter = new BinaryFormatter(); MemoryStream stream = new MemoryStream(); for (int i = 0; i data.Count; i+) formatter.Serialize(stream,datai); Answer:B6、您正在编写一个压缩字节数组的方法。将在名为document的参数中将数组传递到此方法。您需要压缩传入的字节数组并以字节数组的形式返回结果。您应该使用哪个代码段?A.MemoryStream inStream = new MemoryStream(document);GZipStream zipStream = new GZipStream(inStream, CompressionMode.Compress);byte result = new bytedocument.Length;zipStream.Write(result, 0, result.Length);return result;B.MemoryStream outStream = new MemoryStream();GZipStream zipStream = new GZipStream(outStream, CompressionMode.Compress);zipStream.Write(document, 0, document.Length);zipStream.Close();return outStream.ToArray();C.MemoryStream stream = new MemoryStream(document);GZipStream zipStream = new GZipStream(stream, CompressionMode.Compress);zipStream.Write(document, 0, document.Length);zipStream.Close();return stream.ToArray();D.MemoryStream inStream = new MemoryStream(document);GZipStream zipStream = new GZipStream(inStream, CompressionMode.Compress);MemoryStream outStream = new MemoryStream();int b;while (b = zipStream.ReadByte() != -1) outStream.WriteByte(byte)b);return outStream.ToArray();7、您使用以下代码段创建Vehicle类的定义。public class Vehicle public :XmlAttribute(AttributeName = category)String= vehicleType;String= model;XmlIgnoreint year;XmlElement(ElementName = mileage)int miles;ConditionType condition;Vehicle() Public enum ConditionType XmlEnum(Poor) BelowAverage,XmlEnum(Good) Average,XmlEnum(Excellent) AboveAverage;然后创建此Vehicle类的实例。请填写Vehicle类实例的公共字段,如下表所示您需要确定对此Vechile类实例进行序列化时生成的Xml块。A.racer15000ExcellentB.racer15000AboveAverageC.racer15000ExcellentD.carracer15000Excellent答案:A8、您正在定义一个名为MyClass的类,它包含若干个子对象。MyClass包含一个名为ProcessChildren的方法,该方法对子对象执行操作。MyClass对象将是可序列化的对象。您需要确保在重建MyClass对象及其所有子对象之后执行ProcessChildren的方法。您应该执行哪两项操作?(每个正确答案都仅给出了部分解决方案。请选择两个答案)A、 将OnDeserializing属性应用于ProcessChildren方法。B、 将OnSerialized属性应用于ProcessChildren方法。C、 指定MyClass实现IDeserializationCallback接口D、 创建一个调用ProcessChildren的GetObjectData方法E、 指定MyClass从ObjectManager类继承F、 创建一个调用ProcessChildren的OnDeserialization方法答案:CF9、您正在开发一个类库。部分代码需要访问系统环境变量。 只有在调用堆栈中较高位置的调用方不具有必须的权限时,才需要强制抛出运行时SecurityException。您应该使用哪个调用方法?A.set.Deny();B.set.PermitOnly();C.set.Assert();D.set.Demand();答案:D10、您更改名为MyData.xml文件的安全设置。您需要保留现有的继承访问规则。您还需要避免这些规则将来继承更改。您应该使用哪个代码段?A.FileSecurity security = new FileSecurity();security.SetAccessRuleProtection(true,true);File.SetAccessControl(mydata.xml, security);B.FileSecurity security = File.GetAccessControl(mydata.xml); security.SetAuditRuleProtection(true,true);File.SetAccessControl(mydata.xml, security);C.FileSecurity security = new FileSecurity(mydata.xml,AccessControlSections.All);security.SetAccessRuleProtection(true,true);File.SetAccessControl(mydata.xml, security);D.FileSecurity security = File.GetAccessControl(mydata.xml); security.SetAccessRuleProtection(true, true);答案:C11、您正在开发一个调用COM组件的方法。您需要使用声明性安全明确请求运行库执行全面的堆栈审核,您必须确保所有调用方在执行您的方法之前都具有要求的COM Interop信用级别。您应该为方法设置哪种属性?A.SecurityPermission(SecurityAction.LinkDemand,Flags=SecurityPermissionFlag.UnmanagedCode)B.SecurityPermission(SecurityAction.Demand,Flags=SecurityPermissionFlag.UnmanagedCode)C.SecurityPermission(SecurityAction.Deny,Flags = SecurityPermissionFlag.UnmanagedCode)D.SecurityPermission(SecurityAction.Assert,Flags = SecurityPermissionFlag.UnmanagedCode)答案:B12、你正在开发一个方法,以便通过使用MD5算法对数据进行哈希操作以供稍后验证。数据以名为message的字节数组的形式传递到您的方法,您需要使用MD5计算传入参数的哈希。您还需要将结果放入字节数组中。您应该使用哪个代码段?A.HashAlgorithm algo = HashAlgorithm.Create(MD5);byte hash = null;algo.TransformBlock(message, 0, message.Length, hash, 0); B.HashAlgorithm algo = HashAlgorithm.Create(MD5);byte hash = BitConverter.GetBytes(algo.GetHashCode();C.HashAlgorithm algo;algo = HashAlgorithm.Create(message.ToString();byte hash = algo.Hash;D.HashAlgorithm algo = HashAlgorithm.Create(MD5);byte hash = algo.ComputeHash(message);答案:D试题 13你正在开发一个用于在本地文件系统上创建新文件的应用程序。你需要为该文件定义特定的安全设置。你必须拒绝在创建过程中文件继承任何默认的安全设置。您应该怎么办?若要答题,请从操作列表中将三项合适的操作移动到答案区并按正确顺序排列。操作:正确答案:试题14您正在开发一个通过使用最终用户的凭据运行的应用程序。只有作为Administrator组成员的用户才有权运行该应用程序。你填写以下安全代码,以保护应用程序中的敏感数据。Bool isAdmin =false;WindowsBuiltInRole role = WindowsBuiltInRole . Administrator;If(!isAdmin) Throw new Exception(“ User not permitted ”);你需要向此安全代码添加一个代码段,以确保该应用程序会在用户不是Administrator组成的成员时引发异常。您应该使用哪个代码?A. GenercPrincipal currentUser = (GenercPrincipal ) Thread.CurrentPrincipal;isAdmin = currentUser.IsInrole(role.ToString();B. WindowsIdentity currentUser = (WindowsIdentity ) Thread.CurrentPrincipal.Identity;isAdmin = currentUser.Name.EndsWinth(Administrator);C. WindowsPrincipal currentUser =( WindowsPrincipal ) Thread. CurrentPrincipal;isAdmin = currentUser .IsInRole(role);D. WindowsIdentity currentUser = WindowsIdentity.GetCurrent();Foreach(IdentityReference grp in currentUser.Groups ) NTAccount GrpAccount = (NTAccount)grp.Translate(typeof(NTAccount);isAdmin = grp.Value.Epuals(role);if(isAmin) break;答案:C试题15你正在开发一种安全哈希算法来对数据进行哈希验证的方法。数据将以名为message的字节数组方式传递到您的方法。你需要使用SHA1计算传入参数的哈希。你还需要将结果放入名为hash的字节数组中。您应该使用哪个代码?A. SHA1 sha = new SHA1CryptoServiceProvider();Sha.GetHashCode ();Byte hash = sha.Hash;B. SHA1 sha =new SHA1CryptoServiceProvider();Byte hash =null;Sha.TransforBllck(message, 0 , message.Length,hash,0);C. SHA1 sha =new SHA1CryptoServiceProvider();Byte hash = sha.ComputeHash(message);D. SHA1 sha =new SHA1CryptoServiceProvider();Byte hash = BitConverter.Get .GetBytes(sha.GetHashCode);答案:C试题 16您正在创建一个名为Assembly1的程序集。Assembly1包含一个公共方法.全局缓存包含另一个名为Assembly2的程序集.您必须确保只从Assembly2调用公共方法。您应该使用哪个权限类?A. StrongNameIdentityPermissionB. DataProtectionPermissionC. PublisherIdentityPermissionD. GacIdentityPermission答案:A试题 17您正在将一个新程序集加载到应用程序中。您需要覆盖该程序集的默认证据。您需要用公共语言运行时(CLR)向该程序集授予一个权限集,就好像从本地Intranet区域中加载该程序集一样。您需要生成证据集合。您应该使用哪个代码段? A. Evidence evidence=new EvidenceAppDomain.CurrentDomain.Evidence:B. Evidence evidence=new Evidence(); evidenct.AddHost(new Zone(SecurityZone.Intranet);C. Evidence evidence=new Evidence();evidenct.AddAssembly(new Zone(SecurityZone.Intranet);D.Evidence evidence=new Evidence(Assembly.GetExecutingAssembly().Evidence);答案:B试题18您正在编写用于用户身份验证和授权的代码。用户名、密码和角色存储在您的应用程序数据存储区中。您需要建立一个用户安全上下文,用于 IsInRole之类的授权检查。您编写以下代码段以向用户授权。If(!TestPassword(username,password)Throw new Exception(“could not authenticate user”);String userRolesArray = LookupUserRoles(userName);您需要完成此代码,以使其建立用户安全上下文。您应该使用哪个代码段?A.GenericIdentity ident = new GenericIdentity(UserName); GenericPrincipal currentUser = new GenericPrincipal(ident, userRolesArray); Thread.CurrentPrincipal = currentUser;B.WindowsIdentity ident = new WindowsIdentity(userName);WindowsPrinciplal currentUser = new WindowsPrinciplal(ident); Thread.CurrentPrincipal = currentUser;C.NTAccount userNTName = new NTAccount(userName);GenericIdentity ident = new GenericIdentity(userNTNmae.Value); GenericPrincipal currentUser= new GenericPrincipal(ident, userRolesArray); Thread.CurrentPrincipal = currentUser;D.Intptr token = IntPtr.Zero;token = LogonUserUsingInterop(userNmae, encryptedPassword); WindowsImpersonationContext ctx = WindowsIdentity.Impersonate(token);答案:A试题19您编写以下代码。public delegate void FaxDocs(object sender,FaxArgs args);您需要创建一个将调用 FaxDocs 的事件。您应该使用哪个代码段?A. public static event FaxDocs Fax;B. public class FaxArgs:EventArgs private string coverPageInfo; public FaxArgs(string coverInfo) this.coverPageInfo=coverPageInfo; public string CoverPageInformation getreturn this.coverPageInfo C. public class FaxArgs:EventArgs private string coverPageInfo; public string CoverPageInformation getreturn this.coverPageInfo D. public static event Fax FaxDocs;答案:A试题20您正在编写自定义字典。该自定义字典类名为 MyDictionary.您需要确保该字典是类型安全的字典。您应该使用哪个代码段?A. class MyDictionary.Dictionary t = new Dictionary();MyDictionary dictionary = (MyDictionary )t;B. class MyDictionary:IDictionaryC. class MyDictionary:HashTableD. class MyDictionary:Dictionary答案:D试题21您需要确定满足下列条件的类型:l 始终为数字。l 不大于65535您应该选择哪种类型?A. System.UInt16B. intC. System.StringD. System.IntPtr答案:A试题22您正在开发一个将用于员工技能评估的应用程序。此评估由25个对错判断题组成。您需要执行下列任务:l 将每个答案预置为正确。l 最大程度地减少每次评估使用的内存量。您应用使用哪个存储选项?A.BitVector32 skills = new BitVector32(-1);B.BitArray skills = new BitArray(-1);C.BitArray skills = new BitArray(1);D.BitVector32 skills = new BitVector32(1);答案:A23、您需要编写一个简单委托,该委托将接受DateTime参数并返回一个指示操作是否成功的值。您应该使用哪个代码段?Apublic delegate void PowerDeviceOn(DataTime autoPowerOff);B.public delegate int PowerDeviceOn(bool result,DateTime autoPowerOff);C.public delegate bool PowerDeviceOn(object sender,EventsArgs autoPowerOff);D.public delegate bool PowerDeviceOn(DataTime autoPowerOff);答案:D24、你正在创建名为Age的类,您需要确保编写的Age类的对象所构成的集合能被排序。你应该选用哪个代码段?A.public class Age : IComparablepublic int Value;public int CompareTo(object obj)try return Value.ComapreTo(Age) obj).Value); catch return -1; B.public class Agepublic int Value;public object CompareTo(int iValue)try return Value.ComapreTo(iValue); catch throw new ArgumentException(object not an Age); C.public class Agepublic int Value;public object CompareTo(object obj)if (obj is Age)Age_age = (Age) obj;return Value.ComapreTo(obj);throw new ArgumentException(object not an Age);D.public class Age : IComparablepublic int Value;public int CompareTo(object obj)if (obj is Age)Age_age = (Age) obj;return Value.ComapreTo(age.Value);throw new ArgumentException(object not an Age);答案: D25、您编写一个名为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.None)public class Employee :IEmployee C. 将以下属性添加到类定义。ClassInterface(ClassInterfaceType.AutoDual)public class Employee D. 将以下属性添加到类定义。ComVisible(true)public class Employee 答案:B解析:使用VS.Net 做.Net组件这个题目有一个关键之处,需要COM接口与新版本之间保持向前兼容,所以最起码要继承某个类或者接口。所以看选项,继承了接口的答案只有D,其他的就是声明类为COM组件的方法。26、您编写下面的代码段以使用平台调用从 Win32 应用程序编程接口 (API)中 调用函数。string personName = Nel;string msg = Welcome + personName + to club “;bool rc = User32API.MessageBox(0, msg, personName, 0);您需要定义一个可以以最佳方式封送字符串数据的方法原型。您应该使用哪个代码段?A.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); 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.Ansi) public static extern bool MessageBox(int hWnd, String text, String caption, uint type);D.DllImport(user32, CharSet = CharSet.Unicode) public static extern bool MessageBox(int hWnd, String text, String caption, uint type);Answer: D科: (无)解释/参考资料:27.您使用反射获取有关名为 MyMethod 方法的信息。您需要确定派生类是否可以访问MyMethod。你应该怎么做?A.调用的 MethodInfo 类的 IsStatic 属性。B.调用的 MethodInfo 类的 IsAssembly 属性。C.调用的 MethodInfo 类的 IsFamily 属性。D.调用的 MethodInfo 类的 IsVirtual 属性。答案: CExplanation/Reference:解释: IsFamily 属性确定是该方法的类和子类可以访问 onlsecy。28、您需要创建可与COM 一起互操作的类定义。您需要确保COM 应用程序能够创建类的实例并且能够调用GetAddress 方法。您应该使用哪个代码段?A. public class Customer string addressString;public Customer() internal string GetAddress() return addressString; B. public class Customer string addressString;public Customer(string address) addressString = address; public string GetAddress() return addressString; C. public class Customer string addressString;public Customer() public string GetAddress() return addressString; D. public class Customer static string addressString;public Customer() public static string GetAddress() return addressString; 答案: C解析:此题意说的是要创建类而且是与com互操作的类,并且可以调用GetAddress方法,所以并不需要构造函数的重载,所以A排除,BCD就是访问限定符的问题,因为是需要所有方法和类互操作,全需要使用public。29、您需要通过使用平台调用服务从您的托管代码中调用非托管函数。您应该做些什么?A使用COM注册您的程序集,然后从COM引用托管代码。B创建一个类以容纳DLL函数,然后使用托管代码创建原型方法。C将类型库作为程序集导入,然后创建COM对象的实例D为您的托管代码导出类型库。Answer: B解析:回调函数是托管应用程序中可帮助非托管 DLL 函数完成任务的代码。对回调函数的调用将从托管应用程序中,通过一个 DLL 函数,间接地传递给托管实现。在用平台调用调用的多种 DLL 函数中,有些函数要求正确地运行托管代码中的回调函数。30、您正在为在香港居住的客户端开发应用程序。您需要使用一个减号显示负货币值。您应该使用哪个代码段?A.CultureInfo culture = new CultureInfo(zh-HK);Return numberToPrint.ToString(-(0), culture);B.NumberFormatInfo culture = new CultureInfo(zh-HK).NumberFormat; culture.CurrencyNegativePattern = 1;return numberToPrint.ToString(C, culture);C.CultureInfo culture = new CultureInfo(zh-HK);return numberToPrint.ToString(), culture);D.NumberFormatInfo culture = new CultureInfo(zh-HK).NumberFormat;culture.NumberNegativePattern
温馨提示
- 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
- 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
- 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
- 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
- 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
- 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
- 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
最新文档
- 时间的脚印app课件
- 有趣的发现作文500字8篇范文
- 时装销售专业知识培训课件
- 时政知识培训方案策划书课件
- 时尚品牌知识课件
- 农业产品供销合同及质量保障协议
- 作文之星谈攻略写作文打腹稿很重要11篇
- 纪检业务知识培训心得
- 纪昌学射课件
- 纪念鲁迅先生的课件
- 外周前庭系统解剖生理及原则课件
- 建筑工程技术标通用
- 临床执业助理医师呼吸系统
- 建设生态文明ppt模板课件
- T∕CGMA 033001-2018 压缩空气站能效分级指南
- 《创新方法》课程教学大纲
- 钻井作业现场常见安全风险及隐患ppt课件
- REFLEXW使用指南规范.doc
- 赛摩6001B皮带校验说明书
- 气动机械手系统设计(含全套CAD图纸)
- 常用处方药名医嘱拉丁文缩写
评论
0/150
提交评论