Click here to Skip to main content
15,902,189 members
Home / Discussions / C#
   

C#

 
GeneralRe: Import data Pin
Heath Stewart19-Nov-04 10:16
protectorHeath Stewart19-Nov-04 10:16 
GeneralRe: Import data Pin
bouli19-Nov-04 10:29
bouli19-Nov-04 10:29 
GeneralRe: Import data Pin
Nick Parker19-Nov-04 19:41
protectorNick Parker19-Nov-04 19:41 
GeneralRe: Import data Pin
bouli19-Nov-04 21:52
bouli19-Nov-04 21:52 
GeneralRe: Import data Pin
Nick Parker20-Nov-04 5:07
protectorNick Parker20-Nov-04 5:07 
GeneralRe: Import data Pin
bouli20-Nov-04 5:08
bouli20-Nov-04 5:08 
GeneralRe: Import data Pin
Heath Stewart19-Nov-04 10:13
protectorHeath Stewart19-Nov-04 10:13 
Generalenum Questions Pin
niceguyeddie19-Nov-04 6:31
niceguyeddie19-Nov-04 6:31 
I'm new at C#, okay with C++

Lets say hypothetically that i'm making a video game and I want to make a button that fires a weapon.. I've made an enum for my "special keys"... so instead of using the Keys enum which doesn't give the keys any more of a description more than what letter it is. So I wanted to make a new Keys enum called myKeys and do something like this


<br />
enum myKeys <br />
{<br />
     SpecialKey1 = Keys.N,<br />
     FireWeapon  = Keys.P,<br />
     //etc....<br />
}<br />
<br />
protected override void OnKeyUp(KeyEventArgs e)<br />
{<br />
     if (e.KeyCode == myKeys.SpecialKey1)  //Error<br />
     {<br />
            //Do something;<br />
     }<br />
     if (e.KeyCode == Keys.N)  //NO error<br />
     {<br />
            //Do something;<br />
     }<br />
}<br />


What am I doing wrong here?

This is the error...
<br />
 Operator '==' cannot be applied to operands of type 'System.Windows.Forms.Keys' and 'myApp.myKeys'<br />


Seems like neither of the above should work by looking at this error? What going on here? Suggestions for other ways of accomplishing the same task

Thanks for responses guys
GeneralRe: enum Questions Pin
Daniel Turini19-Nov-04 6:55
Daniel Turini19-Nov-04 6:55 
GeneralRe: enum Questions Pin
Dennis C. Dietrich19-Nov-04 6:59
Dennis C. Dietrich19-Nov-04 6:59 
GeneralRe: enum Questions Pin
niceguyeddie19-Nov-04 7:25
niceguyeddie19-Nov-04 7:25 
GeneralRe: enum Questions Pin
Heath Stewart19-Nov-04 8:12
protectorHeath Stewart19-Nov-04 8:12 
GeneralRe: enum Questions Pin
Daniel Turini20-Nov-04 5:47
Daniel Turini20-Nov-04 5:47 
GeneralRe: enum Questions Pin
niceguyeddie22-Nov-04 6:22
niceguyeddie22-Nov-04 6:22 
GeneralRe: enum Questions Pin
Daniel Turini22-Nov-04 6:24
Daniel Turini22-Nov-04 6:24 
Generalpicturebox and imagelist in C# Pin
youssef19-Nov-04 4:44
youssef19-Nov-04 4:44 
GeneralRe: picturebox and imagelist in C# Pin
Heath Stewart19-Nov-04 8:13
protectorHeath Stewart19-Nov-04 8:13 
GeneralRe: picturebox and imagelist in C# Pin
youssef19-Nov-04 8:37
youssef19-Nov-04 8:37 
GeneralRasAPI in C# - connecting after failure Pin
Roland Bär19-Nov-04 3:16
Roland Bär19-Nov-04 3:16 
GeneralRe: RasAPI in C# - connecting after failure Pin
Daniel Turini19-Nov-04 6:53
Daniel Turini19-Nov-04 6:53 
GeneralRe: RasAPI in C# - connecting after failure Pin
Roland Bär21-Nov-04 23:25
Roland Bär21-Nov-04 23:25 
GeneralWindows Service and Sql Server Pin
Anonymous19-Nov-04 2:41
Anonymous19-Nov-04 2:41 
GeneralRe: Windows Service and Sql Server Pin
Dennis C. Dietrich19-Nov-04 3:15
Dennis C. Dietrich19-Nov-04 3:15 
GeneralRe: Windows Service and Sql Server Pin
Daniel Turini19-Nov-04 6:49
Daniel Turini19-Nov-04 6:49 
GeneralRe: Windows Service and Sql Server Pin
Steven Campbell19-Nov-04 7:37
Steven Campbell19-Nov-04 7:37 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.