mirror of
https://github.com/ICDSystems/ICD.Common.Utils.git
synced 2026-04-12 12:07:05 +00:00
Micro-optimization
This commit is contained in:
parent
421a3533db
commit
5eff7bdb6c
1 changed files with 15 additions and 0 deletions
|
|
@ -243,6 +243,21 @@ namespace ICD.Common.Utils
|
||||||
return (T)Enum.ToObject(typeof(T), output);
|
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>
|
/// <summary>
|
||||||
/// Gets all of the set flags on the given enum.
|
/// Gets all of the set flags on the given enum.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue