Visual Studio 正在将字节数组解析为从 Android 发送的文件

Visual Studio Parsing Byte array into File sent from Android

我的 C# 服务器收到一个字节数组,但在将其重新解析为文件时遇到问题。

我收到的某些字节具有负值,例如:-119、-64。

当试图解析进入字节数组的请求时,我收到以下异常:-119 is not a valid value for Byte.

发给我的 android phone 发给我一个字节数组列表,我期待 List<Byte[]>.

谢谢。

一个byte in Java is an eight-bit signed integer. In C# the byte type is unsigned, the corresponding type in C# is an sbyte.

你得到的是 List<sbyte[]>.

如果它来自 Android,请注意您的数据类型。 Java 原始类型和 .Net 并不总是匹配。

A byte in java is signed and a byte in .Net 是无符号的。 你应该使用 sbyte:

List<sbyte[]>