byte[] 到 ArrayList? [英] byte[] to ArrayList?
问题描述
谁能告诉我如何在 Windows Mobile 下使用 C# 将 byte[] 转换为 ArrayList?
Could somebody tell me how can I convert byte[] to ArrayList by using C# under Windows Mobile?
后期
这就像拥有一个包含自定义类型实例的 ArrayList.此列表作为字节数组进入数据库(进入 blob)(转换由数据库 API 完成);我想要的是将 byte[] 恢复为 ArrayList;
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
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屋!