How to save enum settings in Visual Studio project properties?
Posted
by zaidwaqi
on Stack Overflow
See other posts from Stack Overflow
or by zaidwaqi
Published on 2010-05-15T16:21:21Z
Indexed on
2010/05/15
16:24 UTC
Read the original article
Hit count: 158
Hi,
In the Settings tab in Visual Studio, I can see Name, Type, Scope, Value table. Define settings is intuitive if the data type is already within the Type drop-down list i.e. integer, string, long etc.
But I can't find enum anywhere.
How do I save enum settings then?
For now, I have the following which clutter my code too much.
public enum Action
{
LOCK = 9,
FORCED_LOGOFF = 12,
SHUTDOWN = 14,
REBOOT,
LOGOFF = FORCED_LOGOFF
};
and I define Action
as int
in the setting. Then I have to do,
switch (Properties.Settings.Default.Action)
{
case 9: SetAction(Action.LOCK); break;
case 12: SetAction(Action.FORCED_LOGOFF); break;
case 14: SetAction(Action.SHUTDOWN); break;
case 15: SetAction(Action.REBOOT); break;
default: SetAction(Action.LOCK); break;
}
Would be nice if I could simply do something like
SetAction(Properties.Settings.Default.Action);
to replace all above but I dont know how to save enum in setting. Hope my question is clear. Thanks.
© Stack Overflow or respective owner