码迷,mamicode.com
首页 > 其他好文 > 详细

用函数将闹钟练一练

时间:2015-04-12 22:38:57      阅读:139      评论:0      收藏:0      [点我收藏+]

标签:

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

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!