Built-In Conversions

Both the CLR and C# support a number of built-in conversions that can be used with primitive types and some special types like enumerations and delegates. To start our discussion about conversions, and the user-defined ones more specifically, let’s get in the right mindset by looking at some of the built-in ones first.

Numeric Conversions

A large number of numeric conversions exist. Some of those conversions don’t require cast syntax to be used and are called implicit. This means that wherever a number of a specific type is expected, you can supply one of a type that’s implicitly convertible into the expected type. Support for implicit conversions on numbers typically corresponds with those conversions that will not lose ...

Get C# 5.0 Unleashed now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.