You need to return the contents of an isolated storage file as a string. The file is machine-scoped and is named Settings.dat. Which code segment should you use?
You write the following code to implement the MyClass.MyMethod function.
public class MyClass {
public int MyMethod(int arg) {
return arg;
}
}
You need to call the MyClass.MyMethod function dynamically from an unrelated class in your assembly.
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?
You write the following code to call a function from the Win32 Application Programming Interface (API) by using platform invoke.
int rc = MessageBox(hWnd, text, caption, type);
You need to define a method prototype.
Which code segment should you use?
You are writing code for user authentication and authorization. The username, password, and roles are stored in your application data store.
You need to establish a user security context that will be used for authorization checks such as IsInRole. You
write the following code segment to authorize the user.
if (!TestPassword(userName, password))
throw new Exception("could not authenticate user");
String[] userRolesArray = LookupUserRoles(userName);
You need to complete this code so that it establishes the user security context.
Which code segment should you use?
You need to create a class definition that is interoperable along with COM. You need to ensure that COM applications can create instances of the class and can call the GetAddress method.
Which code segment should you use?
You are writing a method that returns an ArrayList named al. You need to ensure that changes to the ArrayList are performed in a thread-safe manner. Which code segment should you use?