I am using VB.NET, at the top is
Option Explicit
However why does the compiler not raise an error when I do :-
obj.ThisFunction(Convert.ToInt32(strMessage))
and the function is :-
Function ThisFunction(id as long)
Surely, Int32 is int and int64 is long? Is there a compiler option in VS 2013 that I can turn on to spot these?
This is not a compile error. If you have written code to explicitly convert
strMessage
to anInt32
, then the compiler assumes you knew what you were doing here.In order to check this is actually an
Int32
you can useInt32.TryParse
Converting an
Int32
to anInt64
is not a compile error even withOption Strict On
because this is a widening conversion (Option Strict On gives a compilation error when it finds implicit narrowing conversions, amongst other things)