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?

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?

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



Leave a Reply 1

Your email address will not be published. Required fields are marked *


networkmanagers

networkmanagers

I agree with the answer.