PrepAway - Latest Free Exam Questions & Answers

Which code segment should you use?

You write the following custom exception class named CustomException.

public class CustomException : ApplicationException
{
public static int COR_E_ARGUMENT = unchecked((int)0x80070057);
public CustomException(string msg) : base(msg)
{
HResult = COR_E_ARGUMENT;
}
}

You need to write a code segment that will use the CustomException class to immediately return control to the COM caller. You also need to ensure that the caller has access to the error code. Which code segment should you use?

PrepAway - Latest Free Exam Questions & Answers

A.
return Marshal.GetExceptionForHR(CustomException.COR_E_ARGUMENT);

B.
return CustomException.COR_E_ARGUMENT;

C.
Marshal.ThrowExceptionForHR(CustomException.COR_E_ARGUMENT);

D.
throw new CustomException(“Argument is out of bounds”);

One Comment on “Which code segment should you use?


Leave a Reply