本文整理匯總了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 ());
}