【发布时间】:2016-05-20 22:08:26
【问题描述】:
我正在尝试从一组颜色中获取唯一的哈希码。根据数组的设置方式,代码必须是唯一的。最终我想使用这个哈希码与另一个从另一个生成的哈希码进行比较(检查它们在同一个索引中是否具有相同的颜色)。
using System;
using System.Collections.Generic;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace WindowsFormsApplication1
{
public class Test
{
public Color[] GridMap { get; set; }
private Color[] ColorSet
{
get
{
var colors = new[]
{
Color.Aquamarine,
Color.Azure,
Color.Red,
Color.Blue
};
return colors;
}
}
public Test()
{
GridMap = new Color[24];
var random = new Random();
for (int i = 0; i < GridMap.Length; i++)
{
GridMap[i] = ColorSet[random.Next(0,3)];
}
}
public ulong GetUniqueCodeFromGridMap()
{
// Dont Know how to implement this yet !
return 0;
}
}
}
【问题讨论】:
标签: c# arrays hash compare unique