Convert byte array to decimal : Decimal convert back and forth : Data Type C# Examples


C# Examples » Data Type » Decimal convert back and forth »

 

Convert byte array to decimal









    
using  System;
using  System.IO;

class  MainClass
{

        public  static  void  Main()  
        {
                byte[]  b  =  null;

                using  (MemoryStream  stream  =  new  MemoryStream())  
                {
                        using  (BinaryWriter  writer  =  new  BinaryWriter(stream))  
                        {
                                writer.Write(285998345545.563846696m);
                                b  =  stream.ToArray();
                        }
                }

                using  (MemoryStream  stream  =  new  MemoryStream(b))  
                {
                        using  (BinaryReader  reader  =  new  BinaryReader(stream))  
                        {
                                Console.WriteLine(reader.ReadDecimal());
                        }
                }

        }
}
    
   
  
   



Output

285998345545.563846696


HTML code for linking to this page:

Follow Navioo On Twitter

C# Examples

 Navioo Data Type
» Decimal convert back and forth