Understanding generic types

stricknyn

Member
Joined
Apr 25, 2006
Messages
11
Programming Experience
5-10
Hi all,

I'm studying for one of the exams towards the MSPD EAD 3.5 certification. One question that I've been getting wrong on the practice test is:

Which of the following are examples of built-in generic types? (Choose all that apply).

A. Nullable
B. Boolean
C. EventHandler
D. System.Drawing.Point

Correct answers are A and C.

I now only get them right because I just remember this question. My concern is that this question will come up on the exam and the choices will be different. So, my question is: How do I identify what is a built-in generic type? Is there a list I can review so that I am better acquainted with how to identify them? Or is there some method I can use to identify them?

Thanks,

Strick
 
Nullable class is not a generic type (while it exist to support the generic type), the Nullable(T) structure is a generic type.
Boolean and Point structures are not generic types.
EventHandler delegate is not generic, EventHandler(T) delegate is.

So none of the types mentioned are generic IMO, but two of them can be if you refer to the correct type, but you have to be explicit and and use the (T) or (Of T) notation for it to have a meaning.
 
Hi JohnH,

That's what kind of scares me. Because the Microsoft Press sample exam state that A and C are generic types.

The questions aren't specific in saying it's a generic type if you use it in the capacity (Of T) that you have. It's just question and answer of A,B,C,or D

Thanks,

Strick
 
I guess that if they put (Of T) on some and not on others then the answer would be obvious, so you would need to remember for which of the types they specify you could add the (Of T) to and still have a real type. Obviously there is no Boolean(Of T) or Point(Of T) so those are not generic types. The other two you can add (Of T) to and it will produce the name of a real generic type.
 
It would also be possible to have a user defined Point(Of T) type, but not Boolean(Of T) since Boolean is a reserved keyword in VB. Still neither of these are built-in generic types as of yet.

Logically there is no benefit of a generic Boolean, it has only True/False meaning. A Point structure have properties that could have different data types for different presicion, currently .Net has two different structures for this, the Point type (Integer) and the PointF type (Single).

The Nullable has a logical purpose to provide this "extra" value to existing value types, the EventHandler does also have a logical relation to generics when you know the signature and common usage. So one could say both these have a natural multi-type purpose which is the goal of generics.
 
Back
Top