This is most of the time sufficient when you need to format date/time.
DateTime.Now.ToString("dd-MMM-yyyy | hh:mm tt");
many times you need to convert string to Datetime and there might be some issues related to Regional settings, so in those cases an easy example is
DateTime dt = DateTime.Parse("11/16/2009 7:51:45 PM", new CultureInfo("en-US"));
==========
If you want to display string upto some decimal places always, do this
int tempInt = 24;
string tempStr = tempInt.ToString("D3");
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment