源码网商城,靠谱的源码在线交易网站 我的订单 购物车 帮助

源码网商城

c# 生成随机时间的小例子

  • 时间:2021-10-24 02:40 编辑: 来源: 阅读:
  • 扫一扫,手机访问
摘要:c# 生成随机时间的小例子
[u]复制代码[/u] 代码如下:
Random random = new Random((int)(DateTime.Now.Ticks));             int i = 0;             while (i < 100)             {                 int hour = random.Next(2, 5);                 int minute = random.Next(0, 60);                 int second = random.Next(0, 60);                 string tempStr = string.Format("{0} {1}:{2}:{3}", DateTime.Now.ToString("yyyy-MM-dd"), hour, minute, second);                 DateTime rTime = Convert.ToDateTime(tempStr);                 Console.WriteLine(rTime.ToString());                 i++;             }             Console.ReadKey();
  • 全部评论(0)
联系客服
客服电话:
400-000-3129
微信版

扫一扫进微信版
返回顶部