It looks like everything is correct. All you might have missing is correct naming of the constant. (Again, please review my previous answer to the question you referenced, in part of namespaces.)
This is how you can use this constant in the most general case, independent from content. It means, it could be done in the code of any type at all in your assembly or any assembly using your assembly (due to
public
access modifiers on both class and members):
int ctrlPressed = GlobalHotkeys.GBH.Constants.CTRL;
int ctrlAltPressed =
GlobalHotkeys.GBH.Constants.CTRL |
GlobalHotkeys.GBH.Constants.ALT;
Note that your use of nested class (
Constant
nested in
GBH
) adds its own part to namespace and the full type name.
And this is how you could use
using
alias:
using Constants = GlobalHotkeys.GBH.Constants;
int ctrlPressed = Constants.CTRL;
int ctrlAltPressed =
Constants.CTRL |
Constants.ALT;
[EDIT]
Do yourself a big favor, just ignore the advice in Solution 2. There is nothing wrong with putting anything is a separate file or on upper layer, but this is merely a way to avoid understanding how things really work, which is, in this case, a very simple thing.
—SA