Click here to Skip to main content
16,006,475 members
Home / Discussions / C#
   

C#

 
GeneralRe: Looping on bitwise parameter? Pin
Luc Pattyn16-Dec-06 15:17
sitebuilderLuc Pattyn16-Dec-06 15:17 
GeneralRe: Looping on bitwise parameter? Pin
Lord Kixdemp16-Dec-06 15:27
Lord Kixdemp16-Dec-06 15:27 
GeneralRe: Looping on bitwise parameter? [modified] Pin
Nader Elshehabi16-Dec-06 17:15
Nader Elshehabi16-Dec-06 17:15 
GeneralRe: Looping on bitwise parameter? Pin
Lord Kixdemp16-Dec-06 17:42
Lord Kixdemp16-Dec-06 17:42 
GeneralRe: Looping on bitwise parameter? Pin
Luc Pattyn16-Dec-06 18:12
sitebuilderLuc Pattyn16-Dec-06 18:12 
GeneralRe: Looping on bitwise parameter? Pin
Nader Elshehabi17-Dec-06 4:03
Nader Elshehabi17-Dec-06 4:03 
AnswerRe: Looping on bitwise parameter? Pin
Guffa16-Dec-06 17:53
Guffa16-Dec-06 17:53 
GeneralRe: Looping on bitwise parameter? Pin
Lord Kixdemp16-Dec-06 18:12
Lord Kixdemp16-Dec-06 18:12 
Crap... Frown | :( Well, here's my current code:

public static string Parameter(ScreenParameter parameters)
{
	foreach(object v in Enum.GetValues(typeof(ScreenParameter)))
	{
		if ((parameters & (ScreenParameter)v) == (ScreenParameter)v)
		{
			// Do processing
		}
	}
}


There's something wrong with MyEnum:

public enum MyEnum
{
	AllOff = 0,
	Bold = 1,
	Blink = 5,
	FgBlack = 30,
	FgRed = 31,
	FgGreen = 32, 
	FgYellow = 33,
	FgBlue = 34,
	FgMagenta = 35,
	FgCyan  = 36,
	FgWhite  = 37,
	FgDefault = 39,
	BgBlack  = 40, 
	BgRed  = 41,
	BgGreen  = 42,
	BgYellow = 43,
	BgBlue  = 44,
	BgMagenta = 45,
	BgCyan  = 46,
	BgWhite  = 47,
}


If I run this, the if body executes on the first 5 values (AllOff, Bold, Blink, FgBlack, FgRed) no matter what I pass to it... However, if I replace MyEnum with this:

public enum MyEnum
{
	One = 1,
	Two = 2,
	Three = 4,
	Four = 8,
	Five = 16,
	Six = 32,
	Seven = 64
}


It works perfectly! WTF | :WTF: WTF | :WTF:

Can you figure out what's wrong? Maybe my laptop is mad at me because... not going into details, what's wrong? Thanks! Wink | ;)

Windows Calculator told me I will die at 28. Frown | :(

GeneralRe: Looping on bitwise parameter? Pin
Robert Rohde16-Dec-06 20:42
Robert Rohde16-Dec-06 20:42 
GeneralRe: Looping on bitwise parameter? Pin
Guffa16-Dec-06 22:24
Guffa16-Dec-06 22:24 
GeneralRe: Looping on bitwise parameter? Pin
Scott Dorman17-Dec-06 11:07
professionalScott Dorman17-Dec-06 11:07 
GeneralRe: Looping on bitwise parameter? Pin
Nader Elshehabi17-Dec-06 3:42
Nader Elshehabi17-Dec-06 3:42 
GeneralRe: Looping on bitwise parameter? Pin
Lord Kixdemp17-Dec-06 6:55
Lord Kixdemp17-Dec-06 6:55 
GeneralRe: Looping on bitwise parameter? Pin
Nader Elshehabi17-Dec-06 7:59
Nader Elshehabi17-Dec-06 7:59 
GeneralRe: Looping on bitwise parameter? Pin
Guffa17-Dec-06 9:09
Guffa17-Dec-06 9:09 
QuestionHi, problem drawing a component to a control Pin
babbelfisken16-Dec-06 13:24
babbelfisken16-Dec-06 13:24 
AnswerRe: Hi, problem drawing a component to a control Pin
Luc Pattyn16-Dec-06 13:57
sitebuilderLuc Pattyn16-Dec-06 13:57 
GeneralRe: Hi, problem drawing a component to a control Pin
babbelfisken16-Dec-06 23:20
babbelfisken16-Dec-06 23:20 
GeneralRe: Hi, problem drawing a component to a control Pin
babbelfisken16-Dec-06 23:39
babbelfisken16-Dec-06 23:39 
QuestionC# Design Pattern Suggestion needed... Pin
cmprogrock16-Dec-06 13:03
cmprogrock16-Dec-06 13:03 
QuestionHow to use the operators DIV and MOD Pin
CodeItWell16-Dec-06 9:51
CodeItWell16-Dec-06 9:51 
AnswerRe: How to use the operators DIV and MOD Pin
ejuanpp16-Dec-06 10:23
ejuanpp16-Dec-06 10:23 
AnswerRe: How to use the operators DIV and MOD Pin
Ravi Bhavnani16-Dec-06 11:31
professionalRavi Bhavnani16-Dec-06 11:31 
QuestionCorrect a date in a textBox Pin
CodeItWell16-Dec-06 8:40
CodeItWell16-Dec-06 8:40 
AnswerRe: Correct a date in a textBox Pin
Luc Pattyn16-Dec-06 9:15
sitebuilderLuc Pattyn16-Dec-06 9:15 

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.