Common Type System—Coercion


Jump to: navigation, search
Visual C# Tutorials
.NET Framework Tutorials

Common Type System

© 2006 Wiley Publishing Inc.

Coercion

Coercion is the process of copying a scalar value from one type into an instance of another. This must occur when the target of an assignment is not of the same type of the right-hand, or assigned, value. For example, consider assigning a 32-bit float to a 64-bit double. We say coercion is widening if the target is of a larger storage capacity, as in the 32-bit to 64-bit conversion specified above, while it is narrowing if the target is of a lesser capacity. Widening coercions are implicitly supported by the runtime, while narrowing coercions can result in loss of information and are thus represented as explicit conversions.



Previous_Page_.gif Next_Page_.gif





Personal tools