IMAP C#引发异常
我正在尝试使用C#实现IMAP 我得到了以下函数:IMAP C#引发异常,c#,imap,C#,Imap,我正在尝试使用C#实现IMAP 我得到了以下函数: public int MailUnreadCount() { imapSw.WriteLine("$ STATUS INBOX (unseen)"); imapSw.Flush(); string res = Response(); Match m = Regex.Match(res, "[0-9]*[0-9]"); return Convert.ToIn
public int MailUnreadCount()
{
imapSw.WriteLine("$ STATUS INBOX (unseen)");
imapSw.Flush();
string res = Response();
Match m = Regex.Match(res, "[0-9]*[0-9]");
return Convert.ToInt32(m.ToString());
}
然后我在网上:
return Convert.ToInt32(m.ToString());
以下错误说明:
Exception thrown: 'System.FormatException' in mscorlib.dll
有人知道问题出在哪里吗
谢谢。您应该像这样使用:
Match m = Regex.Match(res, "[0-9]*[0-9]");
if (m.Success)
{
return Convert.ToInt32(m.Value);
}
m.ToString()
究竟返回什么?试图将我在gmail网站上找到的字符串转换为整数。而m.ToString()
调用返回的具体内容是什么?返回一个表示对象m的字符串。这是正确的,该字符串是什么?如果你不提供确切的价值,我们该如何帮助你呢?谢谢你的建议。看来我从未成功过。知道为什么吗?你能告诉我res变量的值吗?