Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

im reading a book ... and now im in the phase of binary data..converting from string\and\or any other data types to binary and vice versa, using bitconverter ,memorystream,binarywriter,binaryreader.

my question is...what the use of converting data to binary????

why do i need this??? (except from encoding files and such...)

 

10x in advance.

  • Leaders
Posted

Converting a string to binary is useless as it will appear in the file exactly how you wrote it.

However, if you were to store numbers in the file, only the binary data will be stored instead of the string representation of the number.

 

For instance, if you wanted to store the number 2147483467 to a file, you'd have a 10 byte large file if you saved it with the StreamWriter.

If you saved it with the StreamReader, you'd have garbage looking characters like this:

ÿÿÿ, but the file would be only 4 bytes. You can read the number back using the StreamReader.

Also, if someone were to open the file, they would have difficulty figuring out that ÿÿÿ is the 2147483467. :)

Iceplug, USN

One of my coworkers thinks that I believe that drawing bullets is the most efficient way of drawing bullets. Whatever!!! :-(

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...