C# (1)


Extend Date to get an ordinal suffix

  • January 13, 2016
  • C#

Added a simple extension to the Date object as to output an ordinal suffix. using System; using System.Collections.Generic; using System.Linq; using System.Web; namespace StuartsPlayground.App_Code { public static class DateTimeExtensions { public static string ToStringWithOrdinal(this DateTime d) { var result = “”; bool gotOne = false; switch ( d.Day % 100 ) { case 11: case […]

Read more...