Convert.ToByte (Double) converts double number to 8-bit unsigned integer.
Class Sample
Public Shared Sub Main()
Dim doubleVal As Double = 1.1
Dim byteVal As Byte = 0
Try
byteVal = System.Convert.ToByte(doubleVal)
System.Console.WriteLine("{0} as a Byte is: {1}.", _
doubleVal, byteVal)
Catch exception As System.OverflowException
System.Console.WriteLine("OverflowException")
End Try
doubleVal = System.Convert.ToDouble(byteVal)
System.Console.WriteLine("{0} as a Double is: {1}.",byteVal, doubleVal)
End Sub
End Class
Related examples in the same category