手机
当前位置:查字典教程网 >编程开发 >C#教程 >c# 生成随机时间的小例子
c# 生成随机时间的小例子
摘要:复制代码代码如下:Randomrandom=newRandom((int)(DateTime.Now.Ticks));inti=0;whil...

复制代码 代码如下:

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();

【c# 生成随机时间的小例子】相关文章:

c# 匿名方法的小例子

sort page 排序和分页的小例子

C#生成影像金字塔的原理实例

c# 关闭窗体时提示的小例子

C#简单获取时间差的小例子

用C#生成不重复的随机数的代码

c# winform多线程的小例子

c#生成缩略图的实现方法

c#循环中产生伪随机数

c#固定长度的随机字符串例子

精品推荐
分类导航