VOOZH about

URL: https://www.geeksforgeeks.org/c-sharp/decimal-tobyte-method-in-c-sharp/

⇱ Decimal.ToByte() Method in C# - GeeksforGeeks


  • Courses
  • Tutorials
  • Interview Prep

Decimal.ToByte() Method in C#

Last Updated : 11 Jul, 2025
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:
Output:
The Byte value is : 127
Example 2:
Output:
The Byte value is : 0
Example 3: Program for OverflowException
Output:
Exception Thrown: System.OverflowException
Reference:
Comment
Article Tags:

Explore