我在以下代码中遇到了问题。
byte[] array = data as byte[]; // compile error - unable to use built-in conversion
if (array != null) { ...
如果数据确实是字节数组,我只想将数据赋值给数组变量。
byte[] array = new byte[arrayLength];
if (array is byte[])
{
// Your code
}
尝试
if(data.GetType().Name == "Byte[]")
{
// assign to array
}
我一问就意识到数据类型不是对象。
将其设置为对象类型(通过Silverlight中的类型转换器传入),它就可以工作了。