I really really like the conditional operator in C#. It makes my life very much easier in writing logic such as this:
public string FormattedFileName
{
get
{
return string.Format("{0}_{1}_{2}_{3}.xls",
DateTime.Now.Month.ToString().Length == 1
? "0" + DateTime.Now.Month.ToString()
: DateTime.Now.Month.ToString(),
DateTime.Now.Day.ToString().Length == 1
? "0" + DateTime.Now.Day.ToString()
: DateTime.Now.Day.ToString(),
DateTime.Now.Year.ToString(),
"DownLoaded_From_Clients");
}
}
Of course, that means I lose the readability of the code. Anyway, I am just curious what opinion other fellow developers have on this approach of writing code. Thanks. I appreciate both negative and positive comments equally.