Converts a Decimal to an 8-bit unsigned integer.
using System; class MainClass { // Convert the decimal argument; catch exceptions that are thrown. public static void DecimalToS_Byte( decimal argument ) { object SByteValue = null; object ByteValue = null; // Convert the argument to an sbyte value. try { SByteValue = (sbyte)argument; } catch( Exception ex ) { SByteValue = null; } // Convert the argument to a byte value. try { ByteValue = (byte)argument; } catch( Exception ex ) { ByteValue = null; } Console.WriteLine(SByteValue); Console.WriteLine(ByteValue ); } public static void Main( ) { DecimalToS_Byte( 123M ); } }