Click here to Skip to main content
15,888,315 members
Home / Discussions / C#
   

C#

 
GeneralRe: Globalization and Measurement Units Pin
carbon_golem13-May-08 5:10
carbon_golem13-May-08 5:10 
GeneralRe: Globalization and Measurement Units Pin
User 137680013-May-08 5:32
User 137680013-May-08 5:32 
Questionbasic questions about enum Pin
George_George13-May-08 3:29
George_George13-May-08 3:29 
AnswerRe: basic questions about enum Pin
Nissim Salomon13-May-08 4:29
Nissim Salomon13-May-08 4:29 
GeneralRe: basic questions about enum Pin
George_George13-May-08 4:42
George_George13-May-08 4:42 
GeneralRe: basic questions about enum Pin
Nissim Salomon13-May-08 4:56
Nissim Salomon13-May-08 4:56 
GeneralRe: basic questions about enum Pin
George_George14-May-08 1:39
George_George14-May-08 1:39 
GeneralRe: basic questions about enum Pin
Anthony Mushrow13-May-08 5:00
professionalAnthony Mushrow13-May-08 5:00 
Any practical usage? There's probably something, but i can't think of anything.

And on to flags:

[Flags]
public enum MyKeys : int
{
  Null	= 0,
  Up	= 0x01,
  Down	= 0x02,
  Left	= 0x04,
  Right	= 0x08
}

...
MyKeys keys = MyKeys.Up | MyKeys.Right;

if((keys&MyKeys.Right) == MyKeys.Right)
  MessageBox.Show("keys contains MyKeys.Right!");


Each value in the enum represents 1 bit:
0x01 = 0001
0x02 = 0010
0x04 = 0100
0x08 = 1000

So if we use the bitwise operators OR and AND we can add and check for these bits. In the above code:

MyKeys keys = MyKeys.Up | MyKeys.Right;
is the same as
MyKeys keys = 0001 | 1000;
keys is now 1001

keys&MyKeys.Right
is the same as
1001&1000 and the result is 1000

My current favourite word is: Bacon!
-SK Genius

Game Programming articles start -here[^]-

GeneralRe: basic questions about enum Pin
George_George14-May-08 1:34
George_George14-May-08 1:34 
QuestionHow can I add two byte[1] + byte[2]? Pin
merh13-May-08 3:26
merh13-May-08 3:26 
QuestionRe: How can I add two byte[1] + byte[2]? Pin
CPallini13-May-08 3:48
mveCPallini13-May-08 3:48 
AnswerRe: How can I add two byte[1] + byte[2]? Pin
merh13-May-08 3:56
merh13-May-08 3:56 
GeneralRe: How can I add two byte[1] + byte[2]? Pin
Dan Neely13-May-08 4:13
Dan Neely13-May-08 4:13 
GeneralRe: How can I add two byte[1] + byte[2]? Pin
CPallini13-May-08 4:16
mveCPallini13-May-08 4:16 
AnswerRe: How can I add two byte[1] + byte[2]? Pin
merh13-May-08 4:27
merh13-May-08 4:27 
GeneralRe: How can I add two byte[1] + byte[2]? Pin
CPallini13-May-08 4:32
mveCPallini13-May-08 4:32 
AnswerRe: How can I add two byte[1] + byte[2]? Pin
merh13-May-08 5:53
merh13-May-08 5:53 
Questionhow to make a service automatic Pin
prasadbuddhika13-May-08 2:59
prasadbuddhika13-May-08 2:59 
AnswerRe: how to make a service automatic Pin
dan!sh 13-May-08 3:02
professional dan!sh 13-May-08 3:02 
QuestionDisassmble GAC-installed assembly Pin
ctoma200513-May-08 2:45
ctoma200513-May-08 2:45 
QuestionFlicker Problem in GDI+ Pin
hdv21213-May-08 2:12
hdv21213-May-08 2:12 
AnswerRe: Flicker Problem in GDI+ Pin
Anthony Mushrow13-May-08 2:35
professionalAnthony Mushrow13-May-08 2:35 
GeneralRe: Flicker Problem in GDI+ Pin
hdv21213-May-08 5:58
hdv21213-May-08 5:58 
GeneralRe: Flicker Problem in GDI+ Pin
Anthony Mushrow13-May-08 6:07
professionalAnthony Mushrow13-May-08 6:07 
GeneralRe: Flicker Problem in GDI+ Pin
hdv21213-May-08 6:17
hdv21213-May-08 6:17 

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.