Decimal.ToByte() Method in C# Last Updated : 11 Jul, 2025 Summarize Comments Improve Suggest changes Share Like Article Like Report This method is used to converts the value of the specified Decimal to the equivalent 8-bit unsigned integer. Syntax: public static byte ToByte (decimal a); Parameter: a: This parameter specifies the decimal which will be negated. Return Value: An 8-bit unsigned integer equivalent to a will be returned. Exception: This method will give OverflowException if the value i.e. a is less than MinValue or greater than MaxValue. Below programs illustrate the use of Decimal.ToByte(Decimal) Method: Example 1: csharp // C# program to demonstrate the // Decimal.ToByte(Decimal) Method using System; using System.Globalization; class GFG { // Main Method public static void Main() { try { // Declaring the decimal variable Decimal a = 127.97m; // using ToByte() method; byte value = Decimal.ToByte(a); // Display the byte value Console.WriteLine("The Byte value "+ "is : {0}", value); } catch (OverflowException e) { Console.Write("Exception Thrown: "); Console.Write("{0}", e.GetType(), e.Message); } } } Output: The Byte value is : 127 Example 2: csharp // C# program to demonstrate the // Decimal.ToByte(Decimal) Method using System; using System.Globalization; class GFG { // Main Method public static void Main() { try { // Declaring the decimal variable Decimal a = -0.999m; // using ToByte() method; byte value = Decimal.ToByte(a); // Display the byte value Console.WriteLine("The Byte value"+ " is : {0}", value); } catch (OverflowException e) { Console.Write("Exception Thrown: "); Console.Write("{0}", e.GetType(), e.Message); } } } Output: The Byte value is : 0 Example 3: Program for OverflowException csharp // C# program to demonstrate the // Decimal.ToByte(Decimal) Method using System; using System.Globalization; class GFG { // Main Method public static void Main() { try { // Declaring the decimal variable Decimal a = -98.45m; // using ToByte() method; byte value = Decimal.ToByte(a); // Display the byte value Console.WriteLine("The Byte value "+ "is : {0}", value); } catch (OverflowException e) { Console.Write("Exception Thrown: "); Console.Write("{0}", e.GetType(), e.Message); } } } Output: Exception Thrown: System.OverflowException Reference: https://learn.microsoft.com/en-us/dotnet/api/system.decimal.tobyte?view=netframework-4.7.2 Comment More infoAdvertise with us Next Article DateTime.ToOADate() Method in C# I IshwarGupta Follow Improve Article Tags : C# CSharp-method CSharp-Decimal-Struct Similar Reads Decimal.ToSByte() Method in C# This method is used to convert the value of the specified Decimal to the equivalent 8-bit signed integer. A user can also convert a Decimal value to an 8-bit integer by using the Explicit assignment operator. Syntax: public static sbyte ToSByte (decimal value); Here, the value is the decimal number 2 min read Decimal.Subtract() Method in C# This method is used to subtract the one specified Decimal value from another. Syntax: public static decimal Subtract (decimal a1, decimal a2); Parameters: a1: This parameter specifies the minuend. a2: This parameter specifies the subtrahend. Return Value: Result of subtracting a2 from a1. Exceptions 2 min read Decimal.Add() Method in C# This method is used to add two specified decimal values. Syntax: public static decimal Add (decimal a1, decimal a2); Parameters: a1: This parameter specifies the first value to add. a2: This parameter specifies the second value to add. Return Value: Decimal sum of a1 & a2. Exceptions: This metho 2 min read DateTime.ToOADate() Method in C# This method is used to convert the value of this instance to the equivalent OLE Automation date. Syntax: public double ToOADate (); Return Value: This method returns a double-precision floating-point number that contains an OLE Automation date equivalent to the value of this instance. Exception: Ove 2 min read DateTime.ToBinary() Method in C# This method is used to serializes the current DateTime object to a 64-bit binary value that subsequently can be used to recreate the DateTime object. Syntax: public long ToBinary (); Return Value: This method returns a 64-bit signed integer that encodes the Kind and Ticks properties. Below programs 2 min read Decimal.Floor() Method in C# This method is used to round the decimal to the closest integer toward negative infinity. Syntax: public static decimal Floor (decimal d); Parameter: d: This parameter specifies the decimal which will be rounded off. Return Value: If d has a fractional part, the next whole Decimal number toward nega 2 min read Like