G
Gang Zhang
Hi,
I have 2 overloaded functions as below:
myfunc(byval val as Decimal) as string
myfunc(byval val as String) as string
When calling the function with a single like:
dim num1 as single = ...
myfunc(num1)
I get an compiler error saying:
------------------------------------------
error BC30519: Overload resolution failed because no accessible "myfunc" can
be called without a narrowing conversion:
'Public Shared Overloads Function myfunc(val As Decimal) As String':
Argument matching parameter 'val' narrows from 'Double' to 'Decimal'.
'Public Shared Overloads Function myfunc(val As String) As String': Argument
matching parameter 'val' narrows from 'Double' to 'String'.
------------------------------------------
What I don't understand is, should it be widening from Double to Decimal?
Why is the compiler trying to do
narrowing from Double to Decimal?
Thanks!
I have 2 overloaded functions as below:
myfunc(byval val as Decimal) as string
myfunc(byval val as String) as string
When calling the function with a single like:
dim num1 as single = ...
myfunc(num1)
I get an compiler error saying:
------------------------------------------
error BC30519: Overload resolution failed because no accessible "myfunc" can
be called without a narrowing conversion:
'Public Shared Overloads Function myfunc(val As Decimal) As String':
Argument matching parameter 'val' narrows from 'Double' to 'Decimal'.
'Public Shared Overloads Function myfunc(val As String) As String': Argument
matching parameter 'val' narrows from 'Double' to 'String'.
------------------------------------------
What I don't understand is, should it be widening from Double to Decimal?
Why is the compiler trying to do
narrowing from Double to Decimal?
Thanks!