views:

39

answers:

1

Hello

is there are better way to structure this line of code, as you can see, I am changing the format of a string that contains a date.

lblCourseStartDate.Text = String.Format("{0:D}", DateTime.Parse(CourseStartDate));

I just found it untidy that I am converting twice or three times to get the format I want.

Thanks

+2  A: 

You can do DateTime.Parse(CourseStartDate)).ToLongDateString() or DateTime.Parse(CourseStartDate)).ToString("D"), which might be a little cleaner. But, you're basically stuck doing the Parse and then the Format regardless of what you do.

Greg