exam questions

Exam 70-483 All Questions

View all questions & answers for the 70-483 exam

Exam 70-483 topic 2 question 25 discussion

Actual exam question from Microsoft's 70-483
Question #: 25
Topic #: 2
[All 70-483 Questions]

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 'inf. 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 = array1[0].Equals(typeof(int));
  • C. var2 = Convert.ToInt32(array1[0]);
  • D. var2 = ((int[])array1)[0];
Show Suggested Answer Hide Answer
Suggested Answer: A 🗳️
Make a list of integers of the array with = ( (List<int>)arrayl) then select the first item in the list with [0].

Comments

Chosen Answer:
This is a voting comment (?). It is better to Upvote an existing comment if you don't have anything to add.
Switch to a voting comment New
Nyxius
Highly Voted 5 years, 7 months ago
Wrong, you cannot convert ArrayList to List<T>. Correct answer is C. Convert.ToInt32(array1[0]);
upvoted 53 times
...
Vodkaalk
Highly Voted 5 years, 2 months ago
I tried. It's C
upvoted 25 times
...
DaGrooveNL
Most Recent 3 years, 10 months ago
FINAL ANSWER: C
upvoted 1 times
...
johan2020
4 years, 1 month ago
c. is correct
upvoted 3 times
...
mohmou
4 years, 4 months ago
A is wrong the complier say: Cannot convert type 'System.Collections.ArrayList' to System.Collections.Generic.List<int>'
upvoted 2 times
...
Jannie
4 years, 5 months ago
May whoever oversees these comments update the answers because this only confuses us trying to test our knowledge. Thanx!
upvoted 5 times
...
TonyBezerra
4 years, 9 months ago
I tried and the right answer is C.
upvoted 7 times
...
saurin
4 years, 9 months ago
Ans is C ArrayList arr = new ArrayList(); int a = 10; int b = 20; arr.Add(a); b = ((List<int>)arr)[0]; // This return error b =Convert.ToInt32(arr[0]);
upvoted 8 times
...
natsk8freak
5 years ago
The correct answer is definitely C. Just confirmed in the debugger.
upvoted 13 times
...
dosper
5 years, 4 months ago
C is the correct answer.
upvoted 18 times
...
supersunny
5 years, 4 months ago
A. is correct.
upvoted 1 times
noussa
3 years, 11 months ago
C is the correct answer. var2 is a simple int. you can't return a list <int> !!
upvoted 2 times
noussa
3 years, 11 months ago
The correct answer is always C. but I didn't pay attention to what A represents so the right explanation is that you can't cast an ArrayList to List<int>
upvoted 1 times
...
...
...
Community vote distribution
A (35%)
C (25%)
B (20%)
Other
Most Voted
A voting comment increases the vote count for the chosen answer by one.

Upvoting a comment with a selected answer will also increase the vote count towards that answer by one. So if you see a comment that you already agree with, you can upvote it instead of posting a new comment.

SaveCancel
Loading ...
exam
Someone Bought Contributor Access for:
SY0-701
London, 1 minute ago