Example #1
0
        /// <summary>
        /// 将枚举转成int数组
        /// </summary>
        /// <typeparam name="TEnum"></typeparam>
        /// <param name="arg"></param>
        /// <returns></returns>
        public static List <int> ToListNumber <TEnum>(this Enum arg) where TEnum : struct
        {
            var obj1 = arg.ToString();
            var obj2 = obj1.Split(',').ToList();

            return(obj2.Select(t => Convert.ToInt32(EnumHelper.ConvertToEnum <TEnum>(t))).ToList());
        }
Example #2
0
        private void btnOK_Click(object sender, EventArgs e)
        {
            m_loginCredentials.UserName          = txtUsername.Text;
            m_loginCredentials.Passsword         = txtPassword.Text;
            m_loginCredentials.ConnectionAccount = EnumHelper <Connection> .ConvertToEnum(cmbConnection.SelectedItem);

            SerializationCredentialsOfFile();
        }
Example #3
0
        public void GetHighLV()
        {
            var e1 = EnumHelper.ConvertToEnum <UserLV_ENUM>("1");

            Assert.AreEqual(UserLV_ENUM.省级, ((UserLV_ENUM)e1));
        }
Example #4
0
 public static T ToEnum <T>(this string value, T defVal = default(T)) where T : struct
 {
     return(EnumHelper.ConvertToEnum <T>(value.ToString(), defVal));
 }