【发布时间】:2016-06-12 18:49:43
【问题描述】:
对于我的项目,我需要将图像源作为哈希码,例如 28F996F0.jpg。我正在尝试以下代码来获取此值,但有一个错误-无法将类型“字符串”隐式转换为“字节 []”。
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 which is of type byte设置为string,它们的正确语法是public int Width { get; set; } -
Encoding.GetBytes从一个字符串创建一个字节数组......但我不是 100% 确定,这就是你真正想要做的。
标签: c# hashcode gethashcode imageurl