Overload error

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hello, I'm a total newbie to .NET & C# so...

When I use Messagebox to show a string & test it, no problems. i then change
the string to an integer, save, rebuild & test & it comes up with this error:

The best overloaded method match for
'System.Windows.Forms.MessageBox.Show(string)' has some invalid arguments.

I understand the concept of overloading properties etc, but how do I get
around this if i simply decide to change the datatype the message box is
displaying. Do I have to delete the messagebox & do it again? - Thank you for
your input. This is probably more of a .NET Q than C# but (?)

off to a slow start

Ant
 
Me again. Well, I've worked something out. It seems that Messagebox doesn't
have an overload for integers. Can this really be true? Does this mean that
you need to explicitly convert to string, whatever you display with
Messagebox?

Thanks for any input
Ant
 
Ant said:
Me again. Well, I've worked something out. It seems that Messagebox doesn't
have an overload for integers. Can this really be true? Does this mean that
you need to explicitly convert to string, whatever you display with
Messagebox?

Yes. It's not hard though - just call ToString(). Given that the
message box would just have to convert it to a string anyway, it seems
better to me to have one method call than one for each built-in value
type.
 

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