The Keys class contains constants for processing keyboard input. The members of the Keys enumeration consist of a key code and a set of modifiers combined into a single integer value. Do not use the values in this enumeration for combined bitwise operations. The values in the enumeration are not mutually exclusive. You can use one of the following techniques to determine if these keys are activated:.
Call the IsKeyLocked method of the Control class. The following table shows the key code values represented by two enumerated values, representing both the general original equipment manufacturer OEM keys and the more specific U.
For the. NET Framework 2. The older version has been retained for backward compatibility, but it may be deleted in future versions of the. NET Framework. Skip to main content. The following example demonstrates this basic difference between the two kinds of enums:. Every name in an enumeration is assigned an integral value that corresponds to its place in the order of the values in the enumeration.
By default, the first value is assigned 0, the next one is assigned 1, and so on, but you can explicitly set the value of an enumerator, as shown here:. The enumerator Diamonds is assigned the value 1. Subsequent enumerators, if they are not given an explicit value, receive the value of the previous enumerator plus one. In the previous example, Hearts would have the value 2, Clubs would have 3, and so on. Every enumerator is treated as a constant and must have a unique name within the scope where the enum is defined for unscoped enums or within the enum itself for scoped enums.
The values given to the names do not have to be unique. For example, if the declaration of a unscoped enum Suit is this:. Then the values of Diamonds , Hearts , Clubs , and Spades are 5, 6, 4, and 5, respectively. Notice that 5 is used more than once; this is allowed even though it may not be intended. These rules are the same for scoped enums. Unscoped enum constants can be implicitly converted to int , but an int is never implicitly convertible to an enum value.
The following example shows what happens if you try to assign hand a value that is not a Suit :. A cast is required to convert an int to a scoped or unscoped enumerator. However, you can promote a unscoped enumerator to an integer value without a cast. Oct 4, Oct 13, Dec 20, Dec 5, Nov 26, Nov 20, Nov 17, Download the file for your platform. If you're not sure which to choose, learn more about installing packages. Warning Some features may not work without JavaScript. Please try enabling it if you encounter problems.
Search PyPI Search.
0コメント