find the current date and time in csharp

In C#, we can easily find the current date and time using the DateTime class in the System namespace.

main.cs
DateTime currentDateTime = DateTime.Now;
Console.WriteLine("Current Date and Time: " + currentDateTime);
105 chars
3 lines

The output of this code will give you the current date and time in the following format:

main.cs
Current Date and Time: 7/14/2021 9:50:24 AM
44 chars
2 lines

gistlibby LogSnag