-=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- (c) WidthPadding Industries 1987 0|524|0 -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- Socoder -> Off Topic -> X-- vs X>0 Posted : Tuesday, 17 January 2012, 12:35 Afr0 Is while(x--) in C equal to while(x > 0) in C#? Posted : Tuesday, 17 January 2012, 12:35 HoboBen Only if x is positive/unsigned. If x starts at -1, x-- is true (because -2 is true, as it is non-zero). If you can guarantee x is never negative, then yes. Aside: I can never remember the order in which x-- is done; does it return the decremented value, or the value before it was decremented? In which case, if x is initially 0 it may have a different effect. It's best to be explicit with the conditional you suggested. -=-=- blog | work | code | more code Posted : Tuesday, 17 January 2012, 13:11 Afr0 I ended up porting it (and all other implicit boolean statements) as such: do { Window[i] = 0; i += Interval; } while (Convert.ToBoolean(x--)); --v -=-=- Afr0 Games Project Dollhouse on Github - Please fork! Posted : Tuesday, 17 January 2012, 16:13 CodersRule HoboBen Aside: I can never remember the order in which x-- is done; does it return the decremented value, or the value before it was decremented? I don't remember which language this was in, but if I remember correctly... x-- returns the value, THEN decrements it. --x decrements the value, THEN returns it. Posted : Tuesday, 17 January 2012, 18:44 Evil Roy Ferguso Well, that's not entirely an accurate conversion. If x starts at 0, while (x--) { ... } --v will not execute, but do { ... } while (Convert.ToBoolean(x--)) --v WILL execute once. Convert.ToBoolean on ints isn't really "idiomatic" C#; I'd suggest just going with the following if there's no better looping construct: while (x > 0) { x--; ... } --v Posted : Tuesday, 17 January 2012, 23:46 Afr0 Thanks! 