3.6. Conversions with the System.Convert class

The System.Convert class is used to perform various conversions. Using this class we can perform narrow conversions and conversions to unrelated data types. The following is a list of supported conversions:

  • we can convert between Byte, SByte, Int16, Int32, Int64, UInt16, UInt32, UInt64, Single, Double, Decimal, String, and Object;

  • we can convert from Char to Int32, UInt32, String, and Object;

  • Byte, SByte, Int16, Int32, UInt16, UInt32, and String can be converted to Char;

  • we can convert from Boolean to Byte, Char, Int16, Int32, Int64, UInt16, UInt32, UInt64, String, and Object;

  • Byte, SByte, Int16, Int32, Int64, UInt16, UInt32, UInt64, and String can be converted to Boolean;

  • DateTime can be converted to ...

Get A Programmer's Guide to .NET now with O’Reilly online learning.

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