Converts a ulong to a byte .
[Edit]
[System.CLSCompliant(false)] public static byte ToByte (ulong value) |
|
Parameters
- value
- The 64-bit unsigned integer value to be converted.
[Edit]
Returns
value as a byte.
[Edit]
Exceptions
Remarks
Example
The following example demonstrates converting ulong values
to byte values.
C# Example |
using System;
class ConvertByteTest {
static public void Main() {
ulong ulong0 = 0;
ulong ulong1 = 32000;
byte byte0 = Convert.ToByte(ulong0);
Console.WriteLine("(ulong) {0} as byte = {1}",ulong0,byte0);
byte byte1 = Convert.ToByte(ulong1); //Throws an exception.
Console.WriteLine("(ulong) {0} as byte = {1}",ulong1,byte1);
}
}
|
The output is
(ulong) 0 as byte = 0
Exception occurred: System.OverflowException: Value was either too large or
too small for an unsigned byte.
at Convert.ToByte(UInt64 value)
at ConvertByteTest.Main() in
C:\ECMAExamples\ConvertToByte\ConvertUInt64.cs:line 8
Requirements
Namespace: System
Assembly: mscorlib (in mscorlib.dll)
Assembly Versions: 1.0.5000.0, 2.0.0.0