c# - If the Textbox is null this code returns date 1-1-0001 ... I want it to return null or empty string so what can I do? -
datetime fromdate; datetime.tryparseexact(fromdatetextbox.text, "dd/mm/yyyy", null, system.globalization.datetimestyles.none, out fromdate);
check return values of tryparseexact
bool res = datetime.tryparseexact(fromdatetextbox.text, "dd/mm/yyyy", null, system.globalization.datetimestyles.none, out fromdate); if (res == false) { //date not parsable... }
Comments
Post a Comment