Stoitcho Goutsev \(100\) [C# MVP]
10/14/2003 5:37:00 PM
Hi Mr.Tickle.
To have powers of to as defalut for flags doesn't make sense to me.
Usualy flags provide constants often used combination of flags.
For example
enum Styles
{
WS_EX_WINDOWEDGE = 0x00000100L,
WS_EX_CLIENTEDGE = 0x00000200L,
WS_EX_OVERLAPPEDWINDOW = 0x00000300
}
WS_EX_OVERLAPPEDWINDOW (WS_EX_WINDOWEDGE | WS_EX_CLIENTEDGE) = 768.
is it power of 2?
Some of the flags might have more the one bit set to 1 and thay might be not
power of 2. This doesn't makes them *less flags* than the others, though.
B\rgds
100
"Mr.Tickle" <MrTickle@mrmen.com> wrote in message
news:uUN6Q9mkDHA.2676@TK2MSFTNGP11.phx.gbl...
> What i meant was bloody obvious and expected as its a FLAG, why the hell
> would I preform base 10 operations on a base 2 type (Flag)?
> "Mr.Tickle" <MrTickle@mrmen.com> wrote in message
> news:uPpMV8mkDHA.1740@TK2MSFTNGP12.phx.gbl...
> > It should be powers of 2 by default for flags.
> >
> > Thats my point.
> >
> >
> > "Alan Pretre" <no@spam> wrote in message
> > news:#sbsc6mkDHA.4008@TK2MSFTNGP11.phx.gbl...
> > > "Mr.Tickle" <MrTickle@mrmen.com> wrote in message
> > > news:eeFm2tmkDHA.3688@TK2MSFTNGP11.phx.gbl...
> > > > // Run this code and look for his obvious error by the compiler
> > >
> > > What you wrote and what you meant are two different things. The
> compiler
> > is
> > > fine.
> > >
> > > You have:
> > > enum SomeFlags
> > > {
> > > None = 0, // 0000
> > > One, // 0001
> > > Two, // 0010
> > > Three, // 0011
> > > Four, // 0100
> > > Five, // 0101
> > > Six, // 0110
> > > All = One | Two | Three | Four | Five | Six // 0111
> > > };
> > >
> > > You meant:
> > > enum SomeFlags
> > > {
> > > None = 0,
> > > One = 1,
> > > Two = 2,
> > > Three = 4,
> > > Four = 8,
> > > Five = 16,
> > > Six = 32,
> > > All = One | Two | Three | Four | Five | Six
> > > }
> > >
> > > Change your code and it works fine.
> > >
> > > -- Alan
> > >
> > >
> >
> >
>
>