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
You can do
DateTime.Parse(CourseStartDate)).ToLongDateString()orDateTime.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.