Hi Everyone,
I have writing a class that represents a object on a screen. The object has
normal things like X,Y, Width, Height, ZOrder, and it also has drawing
attributes and flags.
It has properties for setting and getting values from instance variables
that represent the above attributes of the class.
For the flags, which are bit values, I have 3 methods, one for setting, one
for removing and one for testing for the flags.
public abstract class ScreenItem
{
....
private uint flags;
public void SetFlags(uint flags)
{
this.flags |= flags;
}
public void RemoveFlags(uint flags)
{
this.flags &= ~flags;
}
public bool HasFlag(uint flag)
{
return (this.flags & flag) == flag;
}
....
}
now the question is should the flags be defined as an enum or another class
with const uints? What is the correct way of defining such a thing in C#
public abstract class ScreenItem
{
....
public enum FlagType { Selectable = 1, Movable = 2, Sizable = 4,
Editable = 8 };
....
}
or
public abstract class ScreenItem
{
....
public class FlagType
{
public const uint Selectable = 1;
public const uint Movable = 2;
public const uint Sizable = 4;
public const uint Editable = 8;
}
....
}
Thanks
AliR.