更新Enum扩展方法

This commit is contained in:
HerobrineXia committed 2026-08-06 01:09:12 +08:00
1 parent 8bfb4f709f
commit 5a6dce8b96
1 file changed
+3
+3
View File
@@ -24,6 +24,9 @@ public static class EnumUtils {
} }
} }
public static bool HasFlagF<T>(this T value, T flag) where T : struct, Enum
=> value.HasFlag(flag) && !EqualityComparer<T>.Default.Equals(flag, default);
/// <summary> /// <summary>
/// 对于具有 <see cref="FlagsAttribute"/> 的枚举,返回其所有 Flag 值。 /// 对于具有 <see cref="FlagsAttribute"/> 的枚举,返回其所有 Flag 值。
/// 建议仅对没有极端值的正数枚举使用。 /// 建议仅对没有极端值的正数枚举使用。