byte[] 到 ArrayList? [英] byte[] to ArrayList?

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

问题描述

谁能告诉我如何在 Windows Mobile 下使用 C# 将 byte[] 转换为 ArrayList?

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

后期

  1. 这就像拥有一个包含自定义类型实例的 ArrayList.此列表作为字节数组进入数据库(进入 blob)(转换由数据库 API 完成);我想要的是将 byte[] 恢复为 ArrayList;

  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;

.NET CF 不提供 BinaryFormatter;

.NET CF does not provide the BinaryFormatter;

推荐答案

所有数组都继承自 ICollection,所以你可以直接使用

All arrays inherit off ICollection, so you can just use

ArrayList list = new ArrayList(bytearray);

虽然我会使用通用的 List我自己使用相同的方法,因为这可以防止对数组中的每个字节值进行装箱.尽管数组不会静态继承相应类型的泛型 IList,但 CLR 在运行时将相关实现添加到每个数组实例(请参阅重要说明 这里)

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)

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

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