Converts double-precision floating-point number to byte
using System;
public class MainClass
{
public static void Main()
{
double doubleVal = 123.123;
byte byteVal = 0;
byteVal = System.Convert.ToByte(doubleVal);
System.Console.WriteLine("{0} as a byte is: {1}.",
doubleVal, byteVal);
// Byte to double conversion cannot overflow.
doubleVal = System.Convert.ToDouble(byteVal);
System.Console.WriteLine("{0} as a double is: {1}.", byteVal, doubleVal);
}
}
Related examples in the same category