문제

I have an enum:

enum Mangment{
ReportsManagment,
NormalUserManagment,
PowerUserManagment
};

Now, I want to create a checkboxlist and allow the user to chose from this 3 options, than i want to get the selection out back as an enum and process it.

This is my code:

private void saveB_Click(object sender, System.EventArgs e)
    {
        try
        {
            foreach (object itemChecked in rolesPermissionsCBL.CheckedItems)
            {
                var permissionsName = itemChecked.ToString();
                ## How do i get the item checked as an enum..?
            }
         }
     }
도움이 되었습니까?

해결책

Mangment enumValue = (Mangment)Enum.Parse(typeof(Mangment), itemChecked.ToString(), true)
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top