Click here to Skip to main content
15,886,578 members
Please Sign up or sign in to vote.
1.50/5 (2 votes)
See more:
Hi guys,
I am wondering how to convert a 1-dimensional array of string to array of bytes and back again. I have tried searching on the web and no answers are what I am looking for. I am really desperate, as I need this code for a database I am building.

Thanks,
iProgramit
Posted
Updated 28-Jul-15 12:59pm
v2
Comments
PIEBALDconsult 28-Jul-15 19:31pm    
An array of strings? You'll need some sort of way of splitting them back up again.
Patrice T 28-Jul-15 19:34pm    
Give an example of what you want
Philippe Mori 28-Jul-15 21:21pm    
Why you want to convert? Database can store strings!
iProgramIt 28-Jul-15 23:23pm    
Custom database

1 solution

Each string is converted to array of bytes and back depending on the encoding you want to use, so this is done by the encoding classes: https://msdn.microsoft.com/en-us/library/system.text.encoding%28v=vs.110%29.aspx[^].

Apparently, as strings are always Unicode strings, the round trip is guaranteed in all cases only if you use encodings representing Unicode UTFs. As to the array of strings, you can encode the boundaries between strings… any way you prefer. I would advise something more certain if you explained me your purpose. For example, it could be XML markup, or anything else.

—SA
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900