本文整理汇总了C#中Key.GetHashCode方法的典型用法代码示例。如果您正苦于以下问题:C# Key.GetHashCode方法的具体用法?C# Key.GetHashCode怎么用?C# Key.GetHashCode使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Key
的用法示例。
在下文中一共展示了Key.GetHashCode方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: OverridesGetHashCode
public void OverridesGetHashCode()
{
var values = new object[] { 1, "A", null };
Key key = new Key(values);
int expectedHash = EqualityExtensions.Equality<Key>(key).GetHashCode(values);
Assert.Equal(expectedHash, key.GetHashCode());
}
示例2: Run
public static void Run()
{
// begin
var key = new Key { Value = 42 };
var result = typeof(string).IsByRef
? key.Value.GetHashCode()
: key.GetHashCode();
// end
Logger.Log("Result: {0}", result);
}
示例3: Run
public static void Run()
{
var type = Type.GetType("System.Int32");
// begin
var key = new Key { Value = 42 };
var result = type == typeof(int)
? key.GetHashCode()
: key.Value.GetHashCode();
// end
Logger.Log("Result: {0}", result);
}
示例4: Set
public void Set(Key key, bool state)
{
if (!_bitmap.Get((key.GetHashCode() & 0x7FFFFFFF) % GroupManager.BitmapSize)) return;
if (!_dic.ContainsKey(key)) return;
_dic[key] = state;
_isCached = false;
_cacheTrueKeys.Clear();
_cacheFalseKeys.Clear();
}
示例5: lockFor
private Lock lockFor(Key location)
{
return openLocks[(((uint) location.GetHashCode()) >> 1)%openLocks.Length];
}
示例6: Set
public void Set(Key key, bool state)
{
if (!_bitmap.Get((key.GetHashCode() & 0x7FFFFFFF) % GroupManager.BitmapSize)) return;
Info info;
if (!_dic.TryGetValue(key, out info)) return;
info.IsEnabled = state;
}
示例7: GetHashCodeTest
public void GetHashCodeTest()
{
var k = new Key("test");
Assert.AreEqual(k.Value.GetHashCode(), k.GetHashCode());
}