我一直在试图做出某种消息解析器,只获取我发送的消息。例如,如果我有消息这样的:消息解析器C#
Viktor Bale (11 aug. 2016 13:20:56):
Hi! How are you?
Not Viktor Bale (11 aug. 2016 13:20:56):
Hi! Good! And you?
Viktor Bale (11 aug. 2016 13:20:56):
Me too! And this message has
Two lines!
Not Viktor Bale (11 aug. 2016 13:20:56):
And this doesn't matter!
我需要写Viktor Bale
这里只是消息的代码,那我tryed:
for (int i = 0; i < wordsList.Count; i++)
{
if (wordsList[i].StartsWith(defaultName))
{
while (!wordsList[i].StartsWith(dialName))
{
messages.Add(wordsList[i]);
}
}
}
wordsList
是我的邮件,从收到的名单txt文件并通过ReadAllLines
读取上面的消息就是列表。
是我的名字,dialName
是我的对话者的名字。
但是,当我启动它,我的应用程序简单地冻结。我应该怎么做?
你永远不会在你的'while'循环增量'i'。所以如果它是真的,那么这个循环会永远运行。或..直到您无法在消息列表中添加更多项目 – MAV
您应该调试您的代码。比如果你仍然无法找到你的无限循环[编辑]后与[mcve] –