
Untitled
By: a guest on
May 22nd, 2012 | syntax:
None | size: 0.80 KB | hits: 18 | expires: Never
enum flag checking flag always returning true
[Flags]
public enum ConsoleStates : byte
{
TopLevel,
All,
MainMenu,
SingleLeagueSelected,
}
public class Program
{
static void Main(string[] args)
{
Program p = new Program();
p.StartUp(args);
}
private bool CheckFlag(ConsoleStates targetVal, ConsoleStates checkVal)
{
return ((targetVal & checkVal) == checkVal);
}
private void StartUp(string[] args)
{
int x = 0;
ConsoleStates states = (ConsoleStates.All | ConsoleStates.MainMenu);
if (CheckFlag(states, ConsoleStates.SingleLeagueSelected))
{
x++;
}
}
}
[Flags]
public enum ConsoleStates : byte
{
TopLevel = 0,
All = 1,
MainMenu = 2,
SingleLeagueSelected = 4,
}