VB gotcha: when If function isn’t equivalent to an If-Then-Else block

Έχουν δημοσιευτεί 25 Νοεμβρίου 11 01:07 μμ | Μπιρμπίλης Γεώργιος 
Just got bitten by the following: Dim takeN As Integer = If(Integer.TryParse(EdTake.Text, takeN), takeN, itemsCount) I had used that instead of writing in 2 lines: Dim takeN As Integer If not Integer.TryParse(EdTake.Text, takeN) then takeN = itemsCount However, there’s an important difference: “If” is a function, so its arguments are evaluated at call-time. The “If” [...]
Δημοσίευση στην κατηγορία: , , , , , , , , , , ,

Σχόλια:

Χωρίς Σχόλια
Έχει απενεργοποιηθεί η προσθήκη σχολίων από ανώνυμα μέλη

About Μπιρμπίλης Γεώργιος

Microsoft MVP J# 2004-2010 Borland Spirit of Delphi 2001 http://zoomicon.com

Search

Go

Ιστορικό Δημοσιεύσεων

Συνδρομές