|
by Patrik Hägne via Legend and truth on 5/5/2010 9:28:00 PM
Here’s a piece of code that might or might not do what you expect. (It depends on what you expect it to do.)Dim someAge = "999"
Dim parsedAge As Integer? = If(someAge = "999", Nothing, Integer.Parse(someAge))
Challenge
What will the parsedAge variable contain?
Answer
It will be a nullable integer with no value, right? Ehh, no wrong!
-So, what will it be?
Well, it will be a nullable integer – that’s the easy part – but it will have a value, zero (0)! Is this what you expected? It’s not what I
... [ read more ]
|
|