Just wondering what the pipe means in this? ive never seen it before:
FileSystemAccessRule fullPermissions = new FileSystemAccessRule(
"Network Service",
FileSystemRights.FullControl | FileSystemRights.Modify,
AccessControlType.Allow);
Cheers
For an enum marked with the [Flags] attribute the vertical bar means 'and', i.e. add the given values together.
Edit: This is a bitwise 'or' (though semantically 'and'), e.g.:
[Flags]
public enum Days
{
Sunday = 0x01,
Monday = 0x02,
Tuesday = 0x04,
Wednesday = 0x08,
Thursday = 0x10,
Friday = 0x20,
Saturday = 0x40,
}
// equals = 2 + 4 + 8 + 16 + 32 = 62
Days weekdays = Days.Monday | Days.Tuesday | Days.Wednesday | Days.Thursday | Days.Friday;
It's a bitwise-OR but semantically you think of it as an AND!
It is normally a bitwise or operator. In this context, it's used on an enum with the flags attribute set.
It's a bitwise OR of two values, presumably it creates a FileAccessRule with both FullAccess and Modify permissions set.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With