标签:
using System;
using System.Collections.Generic;
using System.Text;
using System.Threading;
namespace 用函数把闹钟习题练一练无返回值
{
class Program
{
public void naozhong(DateTime dt,DateTime nz)
{
for (int i = 0; i <= 1000; i++)
{
dt = dt.AddMinutes(1);
Console.WriteLine(dt.ToShortTimeString());
if (dt.ToShortTimeString().Equals(nz.ToShortTimeString()))
{
Console.WriteLine("到点了。");
Console.WriteLine("是否关闭闹钟(Y/N)");
string x = Console.ReadLine();
if (x == "Y")
{
break;
}
else
{
nz = nz.AddMinutes(5);
}
}
}
}
static void Main(string[] args)
{
DateTime dt = DateTime.Now;
Console.WriteLine(dt);
DateTime nz = Convert.ToDateTime("2015-4-12 12:00");
new Program().naozhong(dt,nz);
Console.ReadLine();
}
}
}
标签:
原文地址:http://www.cnblogs.com/lk-kk/p/4420598.html