Im trying to parse a string a DateTime object. No problem there 🙂
My problem comes, when i try to do it directly in a property set method.
I thought i could do this:
private DateTime _fromDate;
public DateTime FromDate
{
get { return _fromDate; }
set { _fromDate = DateTime.Parse(value); }
}
But I get this error:
“Argument 1: cannot convert from ‘System.DateTime’ to ‘string'”
Does anyone know how to do this, if it can be done at all?
Simple Use
valuewill be ofDateTimeas the property is ofDateTime. When someone will assign this property aDateTime objectit will go invalue. In Set that value will be assigned to_fromDate