Converting Byte[] to Double

c#

Solution

`double` requires 8 bytes, so you should get only one from your entire `byte[]`:

BitConverter.ToDouble(input, 0);

returns

3.7179659497173697E+183

Update

But because you're saying it's a `rowversion` value, you should convert it to `long` instead of `double`:

BitConverter.ToInt64(input, 0);

returns

7353252291589177344

Problem

I have a byte[8], which is actually a sequential number. It comes from the RowVersion in a database. I am really just concerned about the last 4 bytes of the 8 byte array. I am trying to do this: ``` Version = BitConverter.ToDouble(t.Version,4) ``` 'Version' is a double. But, I get an error saying that: Destination array is not long enough to copy all the items in the collection. Check array index and length. The value of my 'Version' is: [0]0 [1]0 [2]0 [3]0 [4]0 [5]0 [6]12 [7]102 What am I doing wrong?

Original source