Search code examples
c#arraysbinaryfiles

C# how to write long type array to binary file


I have a long array. How to write this array to a binary file? Problem is that if I convert it into byte array some values are changed.

The array is like:

long array = new long[160000];

Give some code snippet.


Solution

  • The BinaryFormatter will be the easiest.

    Also valuetypes (I assume this is what you mean by long), serializes very efficiently.