How to this in csharp

  • Thread starter Thread starter RA
  • Start date Start date
R

RA

I have the follwoing:

FILE_FLAG = 0x8;
DIR_FLAG=0x4;

NewFlag = FILE_FLAG | DIR_FLAG;

I need to find if FILE_FLAG exists in NewFlag. How to write this in csharp?


Thanks.
 
Something like this:
const int FILE_FLAG = 0x08;

const int DIR_FLAG = 0x4;

int NewFlag = FILE_FLAG | DIR_FLAG;

bool hasFileFlag = NewFlag & FILE_FLAG) == FILE_FLAG;

As an alternative to const you might create an enum with FILE_FLAG and
DIR_FLAG.
 
you can do this the same way that you would in C

if ((NewFlag & FILE_FLAG) == FILE_FLAG)
{
// it does
}

--- Nick
 
Back
Top