Overload resolution vs. Enum's

  • Thread starter Thread starter Phill. W
  • Start date Start date
P

Phill. W

I have two routines

Public Sub Log( ByVal e as eLogLevel, ByVal saMsg as String )
Public Sub Log( ByVal i as Integer, ByVal saMsg as String )

(eLogLevel is a Public Enum)
(We started off with the Integer method, then wanted to add the
Enum overload to clarify the values that should be fed in).

Provided I call /each/ of these overloads with the /correct/ type in
the first argument, I get the correct version being called. However,
if (as many of my lot do), I use

o.Log( 0, "message" )

the compiled (I.L.) code shows the [first] Enum overload being called
and /not/, as I would have expected, the Integer one. Any value other
than zero correctly uses the Integer overload, so why does zero pick
the wrong one?

(I'm using VB.Net, VS 2003, v7.1.3088)

TIA,
Phill W.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top