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
strMessageto anInt32, then the compiler assumes you knew what you were doing here.In order to check this is actually an
Int32you can useInt32.TryParseConverting an
Int32to anInt64is not a compile error even withOption Strict Onbecause this is a widening conversion (Option Strict On gives a compilation error when it finds implicit narrowing conversions, amongst other things)