MessageBox.Show((some_string.Le开发者_JAVA技巧ngth).ToString);
I am getting two errors for this:
The best overloaded method match for 'System.Windows.Forms.MessageBox.Show(string)'
Argument '1': cannot convert from 'method group' to 'string'
Can someone tell me how to do this correctly?
MessageBox.Show((some_string.Length).ToString());
Functions need brackets when they are called, you are missing ()
at the end of ToString
MessageBox.Show((some_string.Length).ToString());
The errors:
Error 1 The best overloaded method match for 'System.Windows.Forms.MessageBox.Show(string)'
This is just saying that it is expecting a string (MessageBox.Show()
), and you did not provide it with one.
Error 2 Argument '1': cannot convert from 'method group' to 'string'
This is saying that you cannot convert a method group (ToString
without brackets to make it a function call) as a string parameter in the required method.
MessageBox.Show((some_string.Length()).ToString());
in you example you have forgotten the parenthesis:
MessageBox.Show((some_string.Length).ToString());
You have to know that, ToString
is not a property, but a method.
So you must use a pair of parenthesis.
MessageBox.Show((some_string.Length).ToString());
精彩评论