Random Date Time - CSharp System

CSharp examples for System:Random

Description

Random Date Time

Demo Code


using System.Text;
using System.Linq;
using System.Collections.Generic;
using System;/*from w w  w . j a  v a2s .  c  o  m*/

public class Main{
        public static DateTime RandomDateTime()
        {
            var start = new DateTime(2010, 1, 1);
            var gen = new Random();
            int range = (DateTime.Today - start).Days;
            return start.AddDays(gen.Next(range));
        }
}

Related Tutorials