The return type of
Item
property of
SqlDataReader
is
Object
as explained here
http://msdn.microsoft.com/en-us/library/y64yaah2.aspx[
^]
When a
Visual Basic
project is created in
Visual Studio
, by default the
Option Strict is off,
hence the implicit conversion from
Object
to
String
or
Integer
are allowed, hence, the second set of statements could be compiled.
If the
Option Strict
is turned on
On
(by right clicking on the project, selecting the properties menu option, and in the compile Tab of the property pages), then the second set of statements will not be compiled and the following error will be displayed
Option Strict On disallows implicit conversions from Object to String, Integer as case may be.
In C Sharp the Explicit cast is a must.
So, I think, it is preferable to use the first set of statements.