|
This is my five cents
if(guess == random || guess != random)
|
|
|
|
|
|
Found in an article approved not too long ago...
And no, I didn't throw out case 5.
public int Volume
{
get { return this.volume; }
set
{
if (value < 0) { this.volume = 0; }
else if (value > 10) { this.volume = 10; }
else { this.volume = value; }
switch ( this.volume )
{
case 0: this.volume = 10; break;
case 1: this.volume = 9; break;
case 2: this.volume = 8; break;
case 3: this.volume = 7; break;
case 4: this.volume = 6; break;
case 6: this.volume = 4; break;
case 7: this.volume = 3; break;
case 8: this.volume = 2; break;
case 9: this.volume = 1; break;
case 10: this.volume = 0; break;
}
this.volume = this.volume * -100;
this.player.Volume = this.volume;
}
}
Regards,
mav
--
Black holes are the places where God divided by 0...
|
|
|
|
|
mav.northwind wrote: no, I didn't throw out case 5.
Why would you? Anyone can see it isn't necessary and the original author has optimised it out for efficiency reasons.
|
|
|
|
|
How about:
this.volume = 10 - this.volume; Or is that too verbose?
mav.northwind wrote: this.volume = this.volume * -100;
So, first prevent setting the volume to any value lower than 0 and than set it way below 0 every time?
mav.northwind wrote: this.player.Volume = this.volume;
Good job causing an endless recursion...
|
|
|
|
|
I just love the effect of
this.volume++;
No trees were harmed in the sending of this message; however, a significant number of electrons were slightly inconvenienced.
This message is made of fully recyclable Zeros and Ones
|
|
|
|
|
an old textbook way to improve your efficiency when your boss is using TLOC
using float will make him much more efficient.
|
|
|
|
|
From one of the articles on this very website a description of a function named Open:
Opens an existing WAV file. Returns a String, which will be blank upon success, and upon error, will contain the reason it failed. This method will throw an exception for a more serious error.
|
|
|
|
|
|
|
|
I think SQL Server calls that "Success with information".
|
|
|
|
|
All errors are equal, but some errors are more equal than others...
(yes|no|maybe)*
|
|
|
|
|
s_mon wrote: All errors are equal, but some errors are more equal than others...
Seems I've heard that before. Maybe at that farm I used to work at?
|
|
|
|
|
public int CharToInt(char pcChar)
{
switch(pcChar)
{
case '0' :
return Convert.ToInt32(Convert.ToString(pcChar));
break;
case '1' :
return Convert.ToInt32(Convert.ToString(pcChar));
break;
case '2' :
return Convert.ToInt32(Convert.ToString(pcChar));
break;
case '3' :
return Convert.ToInt32(Convert.ToString(pcChar));
break;
case '4' :
return Convert.ToInt32(Convert.ToString(pcChar));
break;
case '5' :
return Convert.ToInt32(Convert.ToString(pcChar));
break;
case '6' :
return Convert.ToInt32(Convert.ToString(pcChar));
break;
case '7' :
return Convert.ToInt32(Convert.ToString(pcChar));
break;
case '8' :
return Convert.ToInt32(Convert.ToString(pcChar));
break;
case 'A' :
return 10;
break;
case 'B' :
return 11;
break;
case 'C' :
return 12;
break;
case 'D' :
return 13;
break;
case 'E' :
return 14;
break;
case 'F' :
return 15;
break;
default :
return 0;
}
}
|
|
|
|
|
Please,
Show some mercy and give the coder this:
String Test = "1Fa";
int Answer = int.Parse(Test, NumberStyles.HexNumber);
Steve Wellens
|
|
|
|
|
C#? how about some good ol'
ans = c_val > '9' ? (10 + c_val - 'A') : c_val-'0';
|
|
|
|
|
What's he/she got against the number 9?
Regards
David R
|
|
|
|
|
riced wrote: What's he/she got against the number 9?
Oh, nothing. 9 will get flipped to 6 automagically
Yusuf
Oh didn't you notice, analogous to square roots, they recently introduced rectangular, circular, and diamond roots to determine the size of the corresponding shapes when given the area. Luc Pattyn[^]
|
|
|
|
|
Issue this guy a prescription for a book that covers basic things like this... Good God, is this another guy who thinks he gets a bonus for writing the most (inefficient) code?
|
|
|
|
|
return ( "0123456789ABCDEF".IndexOf ( pcChar ) ) ;
Though it still doesn't support lowercase letters.
|
|
|
|
|
that does not return the right default value though.
|
|
|
|
|
|
What about ... ?
return ( "0123456789ABCDEF".IndexOf ( pcChar.ToUpper ) ) ;
|
|
|
|
|
Never mind the verbose and unoptimized bulk, smell the uncessary (and complained-about-by-the-compiler)
case '0' :
return Convert.ToInt32(Convert.ToString(pcChar));
break;
I love the smell of crap code in the morning...
|
|
|
|