Suppose I'm making a utils library, and among other things I have in it a class that involves key input:
public class KeyInput {
...
public bool IsKeyPressed(Keys key) {
// determine and return whether that key is pressed
}
...
}
The Keys enum is in the standard library, but I'm attempting to make this library so that the user doesn't have to even touch anything outside of it, including the standard library if I can (or at least not to do anything that these utils are intended for). I can use Enum.TryParse()
and have the user put in a string according to the what key they want, but it would be much more preferable if I could actually have an enum for it. What I really want is a duplicate of System.Windows.Forms.Keys
that has an implicit conversion to it, or alternately some way to make it so that whenever someone uses my namespace, it includes the System.Windows.Forms.Keys
enum. Is there any way to do this (or something effectively the same)?