对于我的项目,我需要将图像索引作为像这样的哈希码28F996F0.jpg。我正在尝试下面的代码来获取此值,但有一个错误 - 不能隐式地将类型'字符串'转换为'byte []'。不能隐式地使用C#将类型'字符串'转换为'byte []'
var Image= ImgresponseJson.query.pages[ImgfirstKey].thumbnail.source;
img.ImageData = string.Format("{0:X}.jpg", Image.GetHashCode());
我的JSON对象类是
public class PoiImageAnswer
{
public int Width { set; get; }
public int Height { set; get; }
public byte[] ImageData { set; get; }
}
我无法得到怎样的图像URL转换哈希这样28F996F0.jpg
错误是告诉你到底是什么问题..你试图设置'的ImageData这类型的byte'到'string'还他们正确的语法是'public int Width {get;组; }' – MethodMan
'Encoding.GetBytes'从字符串中创建一个字节数组......但我不是100%肯定的,这就是你真正想要做的。 – Haukinger