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 the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.