O'Reilly logo

C# Primer Plus by Klaus Michelsen

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

User-Defined Implicit and Explicit Conversions

Most programs operate on data of a diverse set of types, ranging from the predefined simple types (int, double, and so on) over the derived predefined .NET types (in the Framework class library) to your own custom made types. If an operation adds two int values together and assigns the result to an int variable, the operation stays within the same type (if the result stays within the range of an int). Sometimes, however, we combine different types in the same operations with an accompanying need to convert data from one type to another. As discussed in Chapter 6, “Types, Part I: The Simple Types,” typical circumstances that require conversions are as follows:

  • A value of one type is assigned to a ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required