I've searched (maybe not enough) but couldn't find an answer.
I want to make a generic function where I can pass any enum to use with a CheckedListBox
(get or set the value).
public enum TypeFlags
{
None = 0x0,
//List of flag
}
private void makeFlagOrBitmask(CheckedListBox list, Type e)
{
int myFlags = 0x0;
//I want to achieve something like that
foreach (Object item in list.CheckedItems)
{
//(TypeFlags)Enum.Parse(typeof(TypeFlags), item);
//So e should be the enum himself, but i can't figure how to do that
myFlags += (int)((e)Enum.Parse(typeof(e), item.tostring()));
}
}
So, I can make/read any flags with a single function.
The problem is that I can't figure out how to pass the enum as I need it in the function.