Groups | Blog | Home
all groups > c# > june 2005 >

c# : Overload error


Ant
6/22/2005 10:52:01 PM
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
Ant
6/22/2005 11:01:02 PM
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

[quoted text, click to view]
Ant
6/22/2005 11:31:02 PM
Thanks very much Jon, You'll probably be seeing a lot more of me here!
regards
Ant

[quoted text, click to view]
Jon Skeet [C# MVP]
6/23/2005 7:23:07 AM
[quoted text, click to view]

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.

--
Jon Skeet - <skeet@pobox.com>
http://www.pobox.com/~skeet
AddThis Social Bookmark Button