字节]到ArrayList的? [英] byte[] to ArrayList?

查看:192
本文介绍了字节]到ArrayList的?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有人能告诉我怎么可以转换字节[]到ArrayList中使用C#在Windows Mobile的?

后来编辑:


  1. 这会是这样具有含自定义类型的实例的ArrayList。这种例子不胜枚举到数据库中(成BLOB)作为字节数组(转换是由数据库API来完成);我要的是恢复的字节[]到ArrayList的;


  2. .NET CF不提供的BinaryFormatter;



解决方案

所有的数组继承了ICollection的,所以你可以只用

  ArrayList的列表=新的ArrayList(ByteArray的);

虽然我会使用泛型List<位>自己使用相同的方法,如在阵列中的每个字节的值的那prevents拳。虽然阵列不staticly继承关的一般的IList用于各个类型中,CLR在运行时添加有关实现到每个阵列实例(见重要注意这里

Could somebody tell me how can I convert byte[] to ArrayList by using C# under Windows Mobile?

Later edit:

  1. this would go like having an ArrayList containing instances of a custom type. This list goes to a database (into a blob) as a byte array (the conversion is done by the database API); What I want is to revert the byte[] to ArrayList;

  2. .NET CF does not provide the BinaryFormatter;

解决方案

All arrays inherit off ICollection, so you can just use

ArrayList list = new ArrayList(bytearray);

although I would use the generic List<byte> myself using the same method, as that prevents boxing of each byte value in the array. Although arrays don't staticly inherit off the generic IList for the respective type, the CLR adds relevant implementations to each array instance at runtime (see the Important Note here)

这篇关于字节]到ArrayList的?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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