Convert a decimal to a byte array and display : decimal convert back and forth « Data Type « C# / CSharp Tutorial






using System;
using System.IO;
 
class MainClass
{
    public static void Main() 
    {
        using (MemoryStream stream = new MemoryStream()) 
        {
            using (BinaryWriter writer = new BinaryWriter(stream)) 
            {

                writer.Write(2123859123.5638466123496m);

                Console.WriteLine(BitConverter.ToString(stream.ToArray()));
            }
        }

    }
}
E8-16-6B-23-EF-99-A9-58-7F-04-00-00-00-00-0D-00








2.32.decimal convert back and forth
2.32.1.Convert a decimal to a byte array and display
2.32.2.Convert byte array to decimal
2.32.3.Converts Decimal numbers to SByte values using the explicit Decimal to SByte conversion.