Ejemplo n.º 1
0
 /// <summary>
 /// 转换成枚举
 /// </summary>
 public static int NumberTypeToValue(NumberTypeEnum enumOption)
 {
     try{
         return((int)enumOption);
     }catch (Exception ex) {
         throw new ArgumentException("enumOption", ex);
     }
 }
Ejemplo n.º 2
0
        /// <summary>
        /// Converts a NumberTypeEnum value to a corresponding string value
        /// </summary>
        /// <param name="enumValue">The NumberTypeEnum value to convert</param>
        /// <returns>The representative string value</returns>
        public static string ToValue(NumberTypeEnum enumValue)
        {
            switch (enumValue)
            {
            //only valid enum elements can be used
            //this is necessary to avoid errors
            case NumberTypeEnum.ALL:
            case NumberTypeEnum.VOICE:
            case NumberTypeEnum.SMS:
                return(stringValues[(int)enumValue]);

            //an invalid enum value was requested
            default:
                return(null);
            }
        }