My Technical Notes

Monday, 28 October 2013

Printing Date and Time

To print both Date and Time using C#, you can use the DateTime.ToString method with a parameter of "g". This is known as the General Date Short Time on MSDN.

// of the following lines are equivalent
Console.WriteLine(string.Format("{0:g}", DateTime.Now));
Console.WriteLine("{0:g}", DateTime.Now);

No comments: