C# provides data Annotation features. For example, a date needs to be stored in the dd/mm/yy in database & while displaying it in the format dd/mm/yyyy with some built in functions and without any manual conversion.

Here is the Model defined that you can use in your project:
  1. public class Example
  2. {
  3. string _date = "50612";
  4. public string date
  5. {
  6. get
  7. {
  8. DateTime dt = DateTime.ParseExact(this._date, "ddMMyy", System.Globalization.CultureInfo.InvariantCulture);
  9. return dt.ToString("dd MMM yyyy");
  10. }
  11. set
  12. {
  13. DateTime dt = DateTime.ParseExact(value, "dd MMM yyyy", System.Globalization.CultureInfo.InvariantCulture);
  14. this._date = dt.ToString("ddMMyy");
  15. }
  16. }
  17. }