c# Error 2 Argument 1: cannot convert from 'string[]' to 'string' 40 37 emailsearch
How can I show the EmailsList
Error 1 The best overloaded method match for 'System.Windows.Forms.MessageBox.Show(string)' has some invalid arguments C:\Users\วิน7\documents\visual studio 2010\Projects\emailsearch\emailsearch\Form1.cs 40 21 emailsearch
开发者_Go百科 if (!string.IsNullOrEmpty(result))
{
Coderbuddy.ExtractEmails helper = new Coderbuddy.ExtractEmails(result);
EmailsList = helper.Extract_Emails();
MessageBox.Show(EmailsList);
}
}
Asuming EmailsList is a list of strings and you want to put it in one messagebox, you could propobly get away with something like:
if (!string.IsNullOrEmpty(result))
{
Coderbuddy.ExtractEmails helper = new Coderbuddy.ExtractEmails(result);
EmailsList = helper.Extract_Emails();
string tmpEmalis;
foreach (string email in emails)
{
tmpEmails = tmpEmails + email + "\r\n";
}
MessageBox.Show(tmpEmalis);
}
If EmailsList is not a List then it's realy hard to guess what it could be.
Your EmailsList is typed like an Array of string. However, MessageBox.Show can only display one string.
So, if you want to display every email, you need to iterate like this :
if (!string.IsNullOrEmpty(result))
{
Coderbuddy.ExtractEmails helper = new Coderbuddy.ExtractEmails(result);
EmailsList emails = helper.Extract_Emails();
foreach (string email in emails)
{
MessageBox.Show(email);
}
}
EmailsList.ToString()
?
If it's your class, implement ToString()
method the way you need.
精彩评论