From 5eff7bdb6ca135ec8cfe67dd3dd1320800be5ae5 Mon Sep 17 00:00:00 2001 From: Chris Cameron Date: Mon, 5 Mar 2018 14:08:00 -0500 Subject: [PATCH] Micro-optimization --- ICD.Common.Utils/EnumUtils.cs | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/ICD.Common.Utils/EnumUtils.cs b/ICD.Common.Utils/EnumUtils.cs index 17354f1..528cd03 100644 --- a/ICD.Common.Utils/EnumUtils.cs +++ b/ICD.Common.Utils/EnumUtils.cs @@ -243,6 +243,21 @@ namespace ICD.Common.Utils return (T)Enum.ToObject(typeof(T), output); } + /// + /// Gets the overlapping values of the given enum flags. + /// + /// + /// + /// + /// + public static T GetFlagsIntersection(T a, T b) + { + int aInt = (int)(object)a; + int bInt = (int)(object)b; + + return (T)Enum.ToObject(typeof(T), aInt & bInt); + } + /// /// Gets all of the set flags on the given enum. ///