Parsing dates from a webpage I have two inputs (TextBox) on my front end.

The following code parses them from their string representation to aDateTime object.  If it fails, it then sets default values.

DateTime dateFrom;
DateTime dateTo;
if (!DateTime.TryParse(txtDateFrom.Text, out dateFrom)) { dateFrom = DateTime.Today.AddDays(-7); }
if (!DateTime.TryParse(txtDateTo.Text, out dateTo)) { dateTo = DateTime.Now; }


However, the code looks bulky. Is there a better way to write it?
You won't be able to change the bulkiness much but there are a few things you can do:


indent your code. It will take more space but it will also be more readable:




DateTime dateFrom;
DateTime dateTo;

if (!DateTime.TryParse(txtDateFrom.Text, out dateFrom)) 
{ 
    dateFrom = DateTime.Today.AddDays(-7); 
}
if (!DateTime.TryParse(txtDateTo.Text, out dateTo)) 
{ 
    dateTo = DateTime.Now; 
}



Wait for C# 6 which has inline-out-variables. This will make it possible to write the TryParse like this:




if (!DateTime.TryParse(txtDateFrom.Text, out DateTime dateFrom))


or even

if (!DateTime.TryParse(txtDateFrom.Text, out var dateFrom))



Use DateTime.UtcNow. By using DateTime.Now you're dependent on the location of your server which might be a problem some time in the future when you host it elsewhere. 
Consider making a datetime picker available in the frontend instead of a textbox. It's a lot more user-friendly and it will avoid invalid dates.