You have a class named Customer and a variable named customers. You need to test whether the customers variable is a generic list of Customer objects. Which line of code should you use?
Suggested Answer:D🗳️
If you want to check if it's an instance of a generic type: return list.GetType().IsGenericType; If you want to check if it's a generic List<T>: return list.GetType().GetGenericTypeDefinition() == typeof(List<>); Reference: Testing if object is of generic type in C# http://stackoverflow.com/questions/982487/testing-if-object-is-of-generic-type-in-c-sharp
A is correct.
Option D will compile, but will not do what is intended. Additionally, the compiler will issue this: warning CS0184: The given expression is never of the provided ('List<Customer>') type
This section is not available anymore. Please use the main Exam Page.70-483 Exam Questions
Log in to ExamTopics
Sign in:
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.
Xavios
Highly Voted 6 years, 1 month agoMitsoshima
Highly Voted 6 years agonoussa
Most Recent 4 years, 5 months agomohmou
4 years, 11 months agowhtvr
5 years, 3 months agosscooter1010
5 years, 4 months agodakuan
5 years, 7 months ago