Which code segment should you use?
You are developing an application that stores data about your company’s sales and technical support teams. You need to ensure that the name and contact information for each person is available as a single collection when a user queries details about a specific team. You also need to ensure that the data collection guarantees type safety.
Which code segment should you use?
Which code segment should you use?
You need to write a code segment that will add a string named strConn to the connection string section of the application configuration file.
Which code segment should you use?
Which code segment should you use?
You are using the Microsoft Visual Studio 2005 IDE to examine the output of a method that returns a string. You assign the output of the method to a string variable named fName.
You need to write a code segment that prints the following on a single line
The message: “Test Failed: “
The value of fName if the value of fName does not equal “John”
You also need to ensure that the code segment simultaneously facilitates uninterrupted execution of the application. Which code segment should you use?
Which code segment should you use?
You are creating a class that performs complex financial calculations. The class contains a method named GetCurrentRate that retrieves the current interest rate and a variable named currRate that stores the current interest rate. You write serialized representations of the class. You need to write a code segment that updates the currRate variable with the current interest rate when an instance of the class is deserialized.
Which code segment should you use?
Which code segment should you use?
You are writing a method to compress an array of bytes. The bytes to be compressed are passed to the method in a parameter named document. You need to compress the contents of the incoming parameter.
Which code segment should you use?
What should you do?
You create an application for your business partners to submit purchase orders. The application deserializes XML documents sent by your partners into instances of an object named PurchaseOrder. You need to modify the application so that it collects details if the deserialization process encounters any XML content that fails to map to public members of the PurchaseOrder object.
What should you do?
What should you do?
You create a class library that contains the class hierarchy defined in the following code segment. (Line numbers are included for reference only.)
01 public class Group {
02 public Employee[] Employees;
03 }
04 public class Employee {
05 public string Name;
06 }
07 public class Manager : Employee {
08 public int Level;
09 }
You create an instance of the Group class. You populate the fields of the instance. When you attempt to serialize the instance by using the Serialize method of the XmlSerializer class, you receive InvalidOperationException. You also receive the following error message: “There was an error generating the XML document.” You need to modify the code segment so that you can successfully serialize instances of the Group class by using the XmlSerializer class. You also need to ensure that the XML output contains an element for all public fields in the class hierarchy.
What should you do?
Which code segment should you use?
You are writing a method to compress an array of bytes. The array is passed to the method in a parameter named document. You need to compress the incoming array of bytes and return the result as an array of bytes.
Which code segment should you use?
Which code segment should you use?
You are developing a server application that will transmit sensitive information on a network. You create an X509Certificate object named certificate and a TcpClient object named client. You need to create an SslStream to communicate by using the Transport Layer Security 1.0 protocol.
Which code segment should you use?
Which code segment should you use?
You are developing a method to hash data for later verification by using the MD5 algorithm. The data is passed to your method as a byte array named message. You need to compute the hash of the incoming parameter by using MD5. You also need to place the result into a byte array.
Which code segment should you use?