此代码只能工作一次,即用户上线并下线。我想循环以便始终提供信息。如:在线11:00,离线11:30,在线11:45,离线12:00。需要逻辑帮助
我该如何解决这个问题?
bool showed =false;
bool nshowd =false;
for (; ;)
{
//chech_online() <- this methods gives true if the person is online on FB
bool check_online =check_online();
if(check_online ==true && !showed)
{
Console.WriteLine("Online !!" +DateTime.Now);
showed = true;
}
else if(check_online ==false && !nshowd)
{
Console.WriteLine("OFFline !!" + DateTime.Now);
nshowd = true;
}
}
仍然不显示用户已登录/关闭_again_,因为'show' /'nshowd'变量不会被重置 – Nuffin 2013-02-21 09:35:15
请参见更新。逻辑已经改变,没有必要有两个不同的布尔值。 – 2013-02-21 09:36:50
谢谢你们:)它帮了我很多。 – John 2013-02-21 10:37:08