Which line of code should you use?

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?

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?

A.
Option A

B.
Option B

C.
Option C

D.
Option D

Explanation:
http://stackoverflow.com/questions/982487/testing-if-object-is-of-generic-type-in-c-sharp



Leave a Reply 7

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

1 × 3 =


TheCoder

TheCoder

A works, check it out, if the question was related to checking if it is generic in general terms then I would have gone customers.GetType().IsGenericType

Xabi

Xabi

A is correct. D should be customers.GetType() == typeof(List) to be correct

Xabi

Xabi

typeof (List with the generic type definition) 🙂

Nasreddine FAREH

Nasreddine FAREH

A

Najlepszy Programista Swiata DAGO

Najlepszy Programista Swiata DAGO

A