ユーザー定義の時間にコードを実行しようとしていますが、datetime変数には実行時間が格納され、時間が変更されたかどうかを確認するために更新されません。C#コンソールアプリケーションで日時変数を常に更新する
static void Main(string[] args)
{
Console.WriteLine("please enter the date in m/d/y h/m/s am/pm format ");
DateTime bombDate = Convert.ToDateTime(Console.ReadLine());
repeat:
//DateTime bombDate = "7/27/2016 4:13:16 AM";
DateTime now = DateTime.Now;
if (bombDate == now)
{
string _str = " this is a virus, you have been hit by a logic bomb ...";
while (true)
{
foreach (char c in _str)
{
SendKeys.SendWait(c.ToString());
Thread.Sleep(200);
}
Thread.Sleep(3000);
}
}
else {
goto repeat;
}
「今」という意味ですか? – user3185569