- Feature Articles
- CodeSOD
- Error'd
- Forums
-
Other Articles
- Random Article
- Other Series
- Alex's Soapbox
- Announcements
- Best of…
- Best of Email
- Best of the Sidebar
- Bring Your Own Code
- Coded Smorgasbord
- Mandatory Fun Day
- Off Topic
- Representative Line
- News Roundup
- Editor's Soapbox
- Software on the Rocks
- Souvenir Potpourri
- Sponsor Post
- Tales from the Interview
- The Daily WTF: Live
- Virtudyne
Admin
"Doesn't .Net have any built in functionality for this type of thing? Java has a NumberFormat class that lets you define how to parse different things like this."
Uh, howsabout TryParse? Did you miss the subject line???
Admin
Sorry, I don't know TryParse from a hole in the ground. I sincerely apologize for not being psychic. The fuctionality in this method doesn't match up with what NumberFormat does.
Admin
It's actually a .net feature (the explaination of the char datatype is from the MSDN page)... but I admit that the code is so simple it's hard to tell if it is C++ or C# (could even be C if there wasn't the public keyword)
Admin
I also guess "bug", but since both of us don't know the specification (if there is any), we can only guess. Would you dare to change it if you had to maintain the program and there was no indication of that function causing problems?
Considering this function takes a nLength parameter and accepts 0-terminated Strings (as well as the mentioned special strings "", "." "-" "-."), I think there is no direct match in eighter C# or Java. Anyway, sometimes it takes less time to re-invent a wheel than to search the libs for a suitable function, especially when the wheel takes 10 lines of code.
Admin
Hells no.
Admin
One workaround, which I'm sure has been suggested already (I'm new on this block, but old elsewhere [EDSAC I]), is to allow WTF the secondary meaning of Why The Fuss?
At least that's what I tell my 13-year-old grand-daughter, although she's big Eminem fan and knows the F-word.
Summary: this IS a useful WTF in both senses. We have learnt some modesty and that _ignorance != _dumbth.
skb
Admin
"Wow that's hardcore. Kinda like building the pyramids without a level and iron tools."
Not really... .NET and the various compilers are freely available. VS.NET isn't. So it's more like building the pyramids without forking out for slightly higher quality limestone from a neighbouring country.
Admin
Using TryParse how can you verify that the conversion was successful - if the number being converted is the number zero?