Monday, March 22, 2010

C# Formating

Date Formating:

DateTime rightnow = DateTime.Now;

string s= rightNow.ToString("MMM dd, yyyy")
string s = String.Format("{0:d}", rightNow)

Currency Formating:

string s = String.Format("{0:c}", price)

SQL db - use decimal(9, 2) for currency


If we wanted to format multiple variables in one shot we could do so:

s = String.Format("{0:c} on {1:d}", price, rightNow)

No comments: