这是 MRE:
FileAccessPermissions permissions = FileAccessPermissions.Read | FileAccessPermissions.Special;
Console.WriteLine(permissions.ToString("G"));
Console.WriteLine(permissions.ToString("F"));
Console.WriteLine(permissions.ToString("D"));
Console.WriteLine(permissions.ToString("X"));
[Flags]
enum FileAccessPermissions
{
None = 0,
Read = 1,
Write = 2,
Execute = 4,
Delete = 8,
Special = 16,
ReadWrite = Read | Write,
}
令我惊讶的是,我找不到一个格式说明符G
和F
产生不同输出的单一示例。我在这个例子中得到了这个:
Read, Special
Read, Special
17
00000011
如果我这样做:
FileAccessPermissions permissions = FileAccessPermissions.ReadWrite;
我会得到:
ReadWrite
ReadWrite
3
00000003