mirror of
https://github.com/ICDSystems/ICD.Common.Utils.git
synced 2026-02-06 08:16:19 +00:00
Micro-optimization
This commit is contained in:
@@ -243,6 +243,21 @@ namespace ICD.Common.Utils
|
||||
return (T)Enum.ToObject(typeof(T), output);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the overlapping values of the given enum flags.
|
||||
/// </summary>
|
||||
/// <typeparam name="T"></typeparam>
|
||||
/// <param name="a"></param>
|
||||
/// <param name="b"></param>
|
||||
/// <returns></returns>
|
||||
public static T GetFlagsIntersection<T>(T a, T b)
|
||||
{
|
||||
int aInt = (int)(object)a;
|
||||
int bInt = (int)(object)b;
|
||||
|
||||
return (T)Enum.ToObject(typeof(T), aInt & bInt);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets all of the set flags on the given enum.
|
||||
/// </summary>
|
||||
|
||||
Reference in New Issue
Block a user