本文整理汇总了C#中System.Enum.GetHashCode方法的典型用法代码示例。如果您正苦于以下问题:C# Enum.GetHashCode方法的具体用法?C# Enum.GetHashCode怎么用?C# Enum.GetHashCode使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Enum
的用法示例。
在下文中一共展示了Enum.GetHashCode方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: EnumHasFlag
/// <summary>
/// Flag 형식의 Enum 에서 특정 Enum값이 <paramref name="flag"/> enum값을 가지는지 파악합니다.
/// </summary>
/// <param name="value"></param>
/// <param name="flag"></param>
/// <returns></returns>
public static bool EnumHasFlag(this Enum value, Enum flag)
{
if(value.GetType() == flag.GetType())
{
var flagHashCode = flag.GetHashCode();
return (value.GetHashCode() & flagHashCode) == flagHashCode;
}
return false;
}
示例2: GetPrarmeterDomain
/// <summary>
/// 返回枚举对应的参数
/// </summary>
/// <param name="roleType"></param>
/// <returns></returns>
public virtual ParameterDomain GetPrarmeterDomain(Enum enumType)
{
return GetParameterDomain(enumType.GetType().Name, enumType.GetHashCode().ToString());
}
示例3: OrNotDeclare
public FlagsResult OrNotDeclare(Enum flag)
{
return this.GetResult(x => x || NotDeclare(this.Source, flag.GetHashCode()));
}
示例4: Equals
public static void Equals(Enum e, object obj, bool expected, bool hashExpected)
{
Assert.Equal(expected, e.Equals(obj));
Assert.Equal(e.GetHashCode(), e.GetHashCode());
if (obj != null)
{
Assert.Equal(hashExpected, e.GetHashCode().Equals(obj.GetHashCode()));
}
}
示例5: AnyIsRight
/// <summary>
/// x是否包含其中一個記錄
/// </summary>
/// <param name="x"></param>
/// <param name="y"></param>
/// <returns></returns>
public static bool AnyIsRight(Enum x, Enum[] y)
{
if (!y.HasRecord()) return false;
return y.Any(y1 => (x.GetHashCode() & y1.GetHashCode()) == y1.GetHashCode());
}
示例6: WriteD
public static void WriteD(this BinaryWriter bw, Enum val)
{
bw.Write(val.GetHashCode());
}
示例7: IsDeclare
public FlagsResult IsDeclare(Enum flag)
{
return this.IsDeclare(flag.GetHashCode());
}
示例8: Declare
public static bool Declare(Enum source, Enum flag)
{
return Declare(source.GetHashCode(), flag.GetHashCode());
}
示例9: Flags
public Flags(Enum source)
{
this.source = source.GetHashCode();
}
示例10: Add
void Add(HappySourceLocation loc, Enum message, params object[] args)
{
string messageName = message.ToString();
string msgfmt = Resources.CompileErrorMessages.ResourceManager.GetString(messageName);
DebugAssert.IsNotNull(msgfmt, "Error message \"{0}\" not found in resources", messageName.ToString());
_sourceErrors.Add(loc.Unit, Util.Format(msgfmt, args), loc.Span, message.GetHashCode(), Severity.FatalError);
}