System.Enum.InternalGetUnderlyingType C# (CSharp) Method

InternalGetUnderlyingType() private method

private InternalGetUnderlyingType ( Type enumType ) : Type
enumType Type
return Type
        private static extern Type InternalGetUnderlyingType(Type enumType);
        

Usage Example

Esempio n. 1
0
        public sealed override Array GetEnumValues()
        {
            if (!IsEnum)
            {
                throw new ArgumentException(SR.Arg_MustBeEnum, "enumType");
            }

            Array values = Enum.GetEnumInfo(this).ValuesAsUnderlyingType;
            int   count  = values.Length;
            // Without universal shared generics, chances are slim that we'll have the appropriate
            // array type available. Offer an escape hatch that avoids a MissingMetadataException
            // at the cost of a small appcompat risk.
            Array result;

            if (AppContext.TryGetSwitch("Switch.System.Enum.RelaxedGetValues", out bool isRelaxed) && isRelaxed)
            {
                result = Array.CreateInstance(Enum.InternalGetUnderlyingType(this), count);
            }
            else
            {
                result = Array.CreateInstance(this, count);
            }
            Array.Copy(values, result, values.Length);
            return(result);
        }
All Usage Examples Of System.Enum::InternalGetUnderlyingType