A program I’ve written that normally works well is now freaking out about Keys.D1 having a value of "LButton | ShiftKey | Space"
Here’s a screen grab of the problem:

ModifierKeys is an enum with the following definition:
public enum ModifierKeys : uint
{
Alt = 1,
Control = 2,
Shift = 4,
Win = 8
}
What on earth is going on here? There are no other references to Keys.D1.
Quoting from Keys Enumeration:
Although the
System.Windows.Forms.Keysenumeration has the[Flags]attribute, the only flags that can actually be safely used as flags are:Keys.ShiftKeys.CtrlKeys.AltAll the remaining values are not “flags” enumeration values. As a result, some combinations of values that are not “flags” values coincidentally happen to combine to form other values that are not “flags” values.
The effect your are seeing is the
Enum.ToString()operator misusing the[Flags]attribute to construct such combinations. This is harmless because theShiftKeyand theSpacekey are never intended to be combined, per the documentation above.