When you run the code, you receive the following error message: "Cannot implicitly convert type ‘object” to ‘int’. An explicit conversion exists (are you missing a cast?)."

You are developing an application.
The application contains the following code segment (Line numbers are included for reference only):

When you run the code, you receive the following error message: "Cannot implicitly convert type ‘object” to ‘int’. An explicit conversion exists (are you missing a cast?)."
You need to ensure that the code can be compiled.
Which code should you use to replace line 05?
A. var2 = ((List<int>)array1) [0];
B. var2 = (int) array1[0];
C. var2 = int.Parse(array1[0]);
D. var2 = array1[0] as int;

microsoft-exams

One thought on “When you run the code, you receive the following error message: "Cannot implicitly convert type ‘object” to ‘int’. An explicit conversion exists (are you missing a cast?)."

Leave a Reply

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


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