using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace Opsoft.NetCore.O3App.Shared { public static class ByteExt { public static TOut ToEnum( this byte value ) { var outputType = typeof( TOut ); if ( outputType.IsEnum ) { if ( outputType.IsEnumDefined( (int)value ) ) { var obj = System.Enum.ToObject( outputType, value ); if ( obj != null ) { return ( TOut )obj; } } } return default( TOut ); } public static bool In(this byte source, params Enum[] enums) { return Array.Exists(enums, current => Convert.ToByte(current) == source); } } }