implicit conversions

ALX

Well-known member
Joined
Nov 16, 2005
Messages
253
Location
Columbia, SC
Programming Experience
10+
I have recently changed my vb2005 project to include 'implicit conversions' in the warning list and was amazed by the number of warnings generated. So I started cleaning up my code to get rid of all these warnings. I came across a piece of code that was copied verbatim from the MSDN website, and noticed that there were several implicit conversion warnings in it also. If there are these warnings in the code written by Microsoft's pro's, maybe I'm just beating myself up by trying to get rid of all of these 'implicit conversion warnings' in my code. Should I be concerned about these warnings? Do most vb.NET programmers leave the switch to list these warnings turned off?
 
First off, good for you for trying to reduce the number of implicits!

Now, on to the actual response.

I notice you say that you turned on Warning for Implicit Conversions, something to consider instead of this 'small' step, is to enable Option Strict on your application(s).

Option Strict turns implict conversions fully into errors, and will force you to code "more responsibly".

Many dont see implicit conversions as a problem, and, VB does handle the farily well, but for me implicit conversions are begging for something to be forgotten. When you leave the job up to the compiler/CLR your taking your hands off the steering wheel, and I prefer to drive ;-)

As for Microsoft's code having some implicits in it, I would say two things:
1) Take the opportunity to improve on their code
2) Never use someone elses mistake/laziness to justify doing the same.


(I'll suffix this by saying the above works in 99.9% of cases, I think I recall one case in which I was forced to leave an implicit conversion for some odd reason...though I may be misremembering that, and it could really be 100%).
 
Back
Top