C#: Convert Double to Integer…and other conversions
No Comments
by Byron Bennett / October 1st, 2008
Type conversions and casting in C# are so whack! Microsoft created the System.Convert class to bring some sanity and predictability to converting from one type to another in C#. Without further ado, to convert a Double to an Integer, you can use: int myInt = System.Convert.ToInt32(myDouble);
The System.Convert class has the following methods:
- ToBoolean
- ToByte
- ToChar
- ToDateTime
- ToDecimal
- ToDouble
- ToInt16
- ToInt32
- ToInt64
- ToSingle
- ToString
- and some more….
Popularity: 41%
Tags: c#
Filed under: ASP.NET/C#

