I code therefore I am.

Posts tagged "format"


February 19, 2010 at 5:59pm
0 notes
Comments (View)

Tags:
CSharp,  format  regex  

Strip HTML Tags

using System.Text.RegularExpressions;
    ...
    public static string StripHTML(string htmlText)
    {
        return Regex.Replace(htmlText, "<(.|\n)*?>", "");
    }

February 5, 2010 at 3:24pm
0 notes
Comments (View)

Tags:
format  datetime  

Unicode Date Format Patterns →

January 22, 2010 at 1:16pm
0 notes
Comments (View)

Tags:
format  CSharp  integer  

Integer to Ordinal

public string AddOrdinal(int num)
{
    switch(num % 100)
    {
        case 11:
        case 12:
        case 13:
            return num.ToString() + "th";
    }

    switch(num % 10)
    {
        case 1:
            return num.ToString() + "st";
        case 2:
            return num.ToString() + "nd";
        case 3:
            return num.ToString() + "rd";
        default:
            return num.ToString() + "th";
    }
}