How do I go about displaying a format string as-is?
I have a property decorated with some data annotations:
[DisplayFormat(DataFormatString = "{0:MM/dd/yyyy}")]
public blah blah { get; set; }
I now have a reference to the format string:
string format = metadata.DisplayFormatString; // == {0:MM/dd/yyyy}
I want to display this format string to the user without manually typing it in my view. Is there a nice way (not replace chars with empty string) to get MM/dd/yyyy from the string format?
I thing using replace is a nice way too. If you’re concerned about clutter in the view, you could put this into an extension method (or even an HTML Helper extension method).