将字符串数组转换为字节数组,然后再转换回vb.net [英] Convert string array to byte array and back again vb.net

查看:112
本文介绍了将字符串数组转换为字节数组,然后再转换回vb.net的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,

我想知道如何将一维字符串数组转换为字节数组并再次返回。我试过在网上搜索,没有答案是我正在寻找的。我真的很绝望,因为我需要这个代码用于我正在构建的数据库。



谢谢,

iProgramit

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

推荐答案

每个字符串都会转换为字节数组并返回,具体取决于您要使用的编码,因此这是由编码类完成的:https://msdn.microsoft.com/en-us/library/ system.text.encoding%28v = vs.110%29.aspx [ ^ ]。



显然,因为字符串总是Unicode字符串,只有在使用代表Unicode UTF的编码时才能保证往返。对于字符串数组,您可以编码字符串之间的边界...您喜欢的任何方式。如果你向我解释你的目的,我会建议更确定的。例如,它可以是XML标记,或其他任何东西。



-SA
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


这篇关于将字符串数组转换为字节数组,然后再转换回vb.net的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆