November 2002
Intermediate to advanced
560 pages
11h 16m
English
As the concepts of object types and interface types have now been explained, albeit very simply, the question of assignment compatibility can be addressed. A simple definition of assignment compatibility for reference types is that a location of type T, where T may be either an object type or an interface type, can refer to any object:
With an exact type of T, or
That is a subtype of T, or
That supports the interface T.
Listing 2.10 demonstrates aspects of assignment compatibility. The program starts by creating values of two different types and two interface references:
A value of type System.Int32 called i
An Object reference called o
A String reference called s
An IComparable reference called ic
Read now
Unlock full access