如何将数组列表转换为字节数组 [英] how to convert array list to byte array

查看:264
本文介绍了如何将数组列表转换为字节数组的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用dxf文件并将其保存..还将坐标保存到数组列表中...如何将数组列表转换为字节数组.... 请立即回复.. ..

i am using a dxf file and saving that file..also saving the coordinate into array list ...how to convert that arraylist into byte array .....please reply immediately....

推荐答案

将数组列表转换为字节数组后将如何处理?通过某种通信链路传输数据?将坐标保存到其他文件中吗?

就个人而言,我要么将其序列化,要么将数据转换为xml数据字符串,而不是将其转换为字节数组.
What are you going to do with the array list after converting it into a byte array? Transmit the data over a communications link of some kind? Save the coordinates in a different file?

Personally, I would either serialize it or convert the data to an xml data string instead of converting it to a byte array.


首先,永远不要使用ArrayList.在v.2.0中引入泛型时,此类型已过时.使用System.Collections.Generic.List.您是否需要使用Cast类型的所有这些麻烦?

序列化数组实例,然后获取一个字节数组,这样您就可以始终对其进行反序列化.我认为您真的不需要这堂课.因此可以将所有数据序列化.

请参阅 http://msdn.microsoft.com/en-us/library/aa349369(v = VS.90).aspx [ http://msdn.microsoft.com/en-us/library/ms733127.aspx [
First of all, never use ArrayList. This type is made obsolete when generic were introduced in v.2.0. Use System.Collections.Generic.List. Do you need all these hassles with type cast?

Serialize the array instance and so get an array of byte, this way you can always deserialize it. I don''t think you really need this class along; so it can be serialized with all your data.

See http://msdn.microsoft.com/en-us/library/aa349369(v=VS.90).aspx[^].

Alternatively, you can use Data Contract to do it all together, see http://msdn.microsoft.com/en-us/library/ms733127.aspx[^].

If you need something specific, please ask a follow-up question.

—SA


这篇关于如何将数组列表转换为字节数组的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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