Summary

This chapter covered conversions in C#. It explained the differences between implicit and explicit conversions in depth. There are several scenarios to consider when performing conversions with the simple types. This chapter discussed automatic conversions in expressions, boxing and unboxing conversions, and explicit conversions that raise exceptions.

Value type conversions involve converting data between structs. This chapter showed how to implement both implicit and explicit conversion operators. It also showed how to use those operators.

The final section was on reference type conversions. It provided some information unique to reference conversions and gave some tips on their implementation.

Get C# 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.