Thanks. Actually I don't even care if the datetime is random or not. I did at first but really I just want the other data to be random. As soon as I add the datetime property to the class it affects the other properties which contain random in them.
p
private string _firstName = string.Empty;
public string FirstName
{
get
{
Random rnd = new Random();
if (rnd.NextDouble() < 0.5)
{
return "Chris";
}
else
{
return "Jack";
}
}
set
{
this._firstName = value;
}
}
private DateTime _myDate;
public DateTime MyDate
{
get
{
return DateTime.Today;
}
set
{
this._myDate = value;
}
}
ny2244111
Member
184 Points
34 Posts
Re: Random property and datetime
May 08, 2012 05:53 PM|LINK
Thanks. Actually I don't even care if the datetime is random or not. I did at first but really I just want the other data to be random. As soon as I add the datetime property to the class it affects the other properties which contain random in them.
p
private string _firstName = string.Empty; public string FirstName { get { Random rnd = new Random(); if (rnd.NextDouble() < 0.5) { return "Chris"; } else { return "Jack"; } } set { this._firstName = value; } }private DateTime _myDate; public DateTime MyDate { get { return DateTime.Today; } set { this._myDate = value; } }