Which of the following lines of code should you use inside the Draw method to accomplish this goal?

You are writing code for a new method named Process:

The code receives a parameter of type object. You need to cast this object into the type Polygon. At times, the value of o that is passed to the method might not be a valid Polygon value. You need to make sure that the code does not generate any System.InvalidCastException errors while doing the conversions. Which of the following lines of code should you use inside the Draw method to accomplish this goal?
A. Polygon p = (Polygon) o;
B. Polygon p = o is Polygon;
C. Polygon p = o as Polygon;
D. Polygon p = (o != null) ? o as Polygon : (Polygon) o;

microsoft-exams

Leave a Reply

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


The reCAPTCHA verification period has expired. Please reload the page.