|
It's all done with mirrors.;)
|
|
|
|
|
|
|
if ((a == a) || (a != a))
{
MessageBox.Show("That is correct, well done!!!");
}
WTF?
There are 10 types of people in the world, those who understand binary and those who dont.
|
|
|
|
|
Strange that the author of the code didn't write this:
<br />
if ((a == a))<br />
{<br />
MessageBox.Show("That is correct, well done!!!");<br />
}
|
|
|
|
|
Or even just:
MessageBox.Show("That is correct, well done!!!");
There are 10 types of people in the world, those who understand binary and those who dont.
|
|
|
|
|
"if (a == a)" actually has a meaning if a is of type double: double.NaN isn't equal to itself. Try it.
|
|
|
|
|
maybe, but if that's the only case is there a way to test if a double is NaN directly? That'd be safer than hoping a clueless maintainance programmer wouldn't delete the explanatory comment as unneeded clutter on one update and then remove the if (a == a) test as useless on the next pass.
--
You have to explain to them [VB coders] what you mean by "typed". their first response is likely to be something like, "Of course my code is typed. Do you think i magically project it onto the screen with the power of my mind?" --- John Simmons / outlaw programmer
|
|
|
|
|
That's why System.Double contains the method public static bool IsNaN(double d) { return d != d; }
|
|
|
|
|
Better would be
if ((a == a) && !(a != a))
{
MessageBox.Show("That is correct, well done!!!");
}
to make it clear
Greetings from Germany
|
|
|
|
|
There's like two levels of redundancy in there. It's sorta cool in a demented way.
|
|
|
|
|
The ones I find really silly and I see quite often in our codeset are like
boolIsFive = val = "5" ? true : false
Correction:
boolIsFive = val == "5" ? true : false;
-- modified at 8:14 Wednesday 6th June, 2007
|
|
|
|
|
Sameer Alibhai wrote: I see quite often in our codeset
Constantly "Saving the day" should be taken as a sign of organizational dysfunction rather than individual skill - Ryan Roberts[^]
|
|
|
|
|
|
Sameer Alibhai wrote: bool IsFive = val = "5" ? true : false
You know the intern that produces this?
You could tell him the secret hack
bool IsFive = (val == "5"); I presume the assignment of "5" was a typo?
Failure is not an option - it's built right in.
|
|
|
|
|
That is correct, thank you.
Here's the VB.net version
btnSubmit.Visible = IIf(_mode = "Read", false, true)
|
|
|
|
|
When it will not execute?
Answer is a = 10 and a = 11
Regards,
Sylvester G
sylvester_g_m@yahoo.com
|
|
|
|
|
Hi! Several days ago I debugged one service in customer machine, and so there weren’t any symbols and debug information. But this is not a big problem. The most important problem was empty catch blocks in the application.
For example,
try
{
File.Move(source, dest);
}
catch
{}
//… Other code here.
It was terrible, because this service changed information in the database. And one another service tried to remove file of information is correct in the database. I’ve spent a lot time with cordbg before I’ve found issue. It was problem with user’s permissions.
Empty catches are really horror. Don’t use theirs.
|
|
|
|
|
Ooh - this is one of those issues where people come down on one side or the other. Some people seem to like silently consuming exceptions so that they don't actually have to do any *hard* coding to deal with the exceptions - they should be hunted down and tarred and feathered.
Deja View - the feeling that you've seen this post before.
|
|
|
|
|
Everybody is probably gonna hate me for saying this but there are times when you don't want anything to happen when you catch an exception. I do it often. I put comments in the braces to explain why though. Please don't hunt me down.
Peace
There are 10 types of people in the world, those who understand binary and those who dont.
|
|
|
|
|
True, especially when .net throws exceptions willy nilly.
.net is a box of never ending treasures, every day I get find another gem.
|
|
|
|
|
If you have one of those, go hunting for an alternate approach that does not throw an exception.
In .NET 1.x, it appeared there was no way to convert a string to an integer without getting an exception if it failed. However, you could go via the Double type's TryParse method and then cast the Double to an int . Double cannot represent the whole range of a 64-bit integer so this approach isn't suitable for numbers this large.
Thankfully .NET 2.0 added a whole load of TryParse methods for the other basic types. (They do much the same work as the old Double.TryParse ).
|
|
|
|
|
Oooohh! The "Damn the torpedoes!" approach to coding, huh? Funny, I just about never write an exception handler that didn't actually handle the exception.
If your logic depends on an exception happening, you haven't solved the logic problem properly.
|
|
|
|
|
|
Thankfully, there's no place to vote on it. THAT'S an article??! I've seen more information on a frickin' sticky note!
|
|
|
|