本文整理汇总了C#中System.Color.GetHashCode方法的典型用法代码示例。如果您正苦于以下问题:C# Color.GetHashCode方法的具体用法?C# Color.GetHashCode怎么用?C# Color.GetHashCode使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Color
的用法示例。
在下文中一共展示了Color.GetHashCode方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Test_Equals
public void Test_Equals()
{
var a = new Color (1, 2, 3, 4);
var b = new Color (1, 2, 3, 4);
var c = new Color (1, 2, 3, 0);
Assert.IsTrue (a.Equals (b));
Assert.IsTrue (a == b);
Assert.AreEqual (a.GetHashCode (), b.GetHashCode ());
Assert.IsFalse (a.Equals (c));
Assert.IsFalse (a == c);
Assert.AreNotEqual (a.GetHashCode (), c.GetHashCode ());
}
示例2: TestColorModel
public void TestColorModel()
{
var c1 = new Color();
Assert.AreEqual(c1, default(Color));
Assert.IsTrue(c1 == default(Color));
Assert.IsFalse(c1 != default(Color));
Assert.IsTrue(((object)c1).Equals((object)default(Color)));
Assert.AreEqual("00000000", c1.ToString());
var c2 = new Color(255, 0, 0, 0);
Assert.AreEqual(c2.R, 255);
Assert.AreEqual(c2.G, 0);
Assert.AreEqual(c2.B, 0);
Assert.AreEqual(c2.A, 0);
Assert.AreEqual(Color.Red.ToString(), c2.ToString());
Assert.AreEqual(Color.Red.GetHashCode(), c2.GetHashCode());
}
示例3: WriteColor
private void WriteColor(string fieldName, Color value)
{
var bytes = BitConverter.GetBytes(value.GetHashCode());
var offset = Marshal.OffsetOf(typeof(DevDesc), fieldName).ToInt32();
Marshal.Copy(bytes, 0, IntPtr.Add(handle, offset), bytes.Length);
}
示例4: TestHashCode
public void TestHashCode ()
{
var color1 = new Color (0.1);
var color2 = new Color (0.1);
Assert.True (color1.GetHashCode () == color2.GetHashCode ());
color2 = Color.FromHsla (color2.Hue, color2.Saturation, .5);
Assert.False (color1.GetHashCode () == color2.GetHashCode ());
}