attributes is of type FileAttributes . This type is enum , the type of value. Is this not FileAttributes? ( Nullable<FileAttributes> ), so it just cannot be null .
Each enum consists of a list of named values, but each of them is converted / converted to some integer (int) values. In many places, C # allows you to “use” this conversion and (somewhat) process enum values as if they were ints, but still they are not.
For example, the operator and does what you expect - it executes binary I. Thus, if the enum value converted to integer has the corresponding bit (s), you will get some non-zero result.
In the "good old way" check for the presence of some flags / bits in any status. You can often see an expression like foo & FLAG != 0 , which checks whether the flag is set, or foo & (FLAG|BLAG) != 0 , which checks whether either of these two is set. This is a bit erroneous / dangerous, because if someone changes the FLAG by a few bits, then such expressions will check if the ANY bit is set, and not if such a "multi-bit flag" is set. This is why you can also often see foo & FLAG == FLAG , which applies a bitmask and checks if the IS result is a bitmask, so it checks to see if all bits of the mask are set.
Here, in your case, this is exactly so. Since in this expression you are ANDing and COMPARING with the same mask, you effectively check if ALL mask bits are set. But superfluous, since FileAttributes is clearly indicated as [Flags], the Hidden value has only one bit, so! = 0 will be enough.
However, in such cases (checking flags, not fancy bitmaps) you can try to use the Enum.HasFlag method, most people will advise you to use it, since it is intended for such cases;)
This, however, is not always the best choice. Please look:
.. but I would be surprised if this were a problem for you. Optimization up to this point is very rarely needed.