字节列表的序列化:仅使用base-64 [英] Serialization of a byte list: only with base-64

查看:83
本文介绍了字节列表的序列化:仅使用base-64的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述


大家好!

Hello everyone !

我写了一个描述文件格式的xsd。在里面,我将SimpleType描述为字节列表:

I wrote an xsd that describes a file format. Inside, I described a SimpleType as a byte list:


<xs:simpleType name="Ubytes">
 <xs:list itemType="xs:unsignedByte" />
</xs:simpleType>

推荐答案

唯一的二进制数据 序列化 我知道xsd.exe支持的是base64binary和hex(所以xsd类型应该是hexbinary):

the only binary data serialization I know xsd.exe supports are base64binary and hex (so the xsd type should be hexbinary):



[XmlElement(DataType =" hexBinary")] &NBSP;&NBSP;

公共字节[] HexBytes;


[XmlElement(DataType = "hexBinary")]  
public byte [] HexBytes;

 

In您的情况有一个问题:.net不完全支持xsd:list。

In your case there is anotehr issue: the xsd:list is not fully supported by .net.

如果您关心模式,我建议使用base64binary或hexBinary。前者效率最高。

If you care in control of the schema I suggest use base64binary or hexBinary. The former is most efficient.

 

 


这篇关于字节列表的序列化:仅使用base-64的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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