Difference between revisions of "6236 Programmering I Agenda/Date time"

From Teknologisk videncenter
Jump to: navigation, search
(Created page with "DateTime d = new DateTime(2015, 12, 31, 22, 25, 05); System.Console.WriteLine(d.ToString("dd.MM.yyyy HH:mm:ss"));")
 
Line 1: Line 1:
 +
Hvis der skal gemmes en dato i C# kan det gøres i datatypen DateTime.
 +
 +
 +
 +
<source lang=Csharp>
 +
//Opret en DateTime med datoen 31/12-2015 Kl 22:25:05
 
DateTime d = new DateTime(2015, 12, 31, 22, 25, 05);
 
DateTime d = new DateTime(2015, 12, 31, 22, 25, 05);
 +
 +
//Udskriv DateTime i formatet
 
System.Console.WriteLine(d.ToString("dd.MM.yyyy HH:mm:ss"));
 
System.Console.WriteLine(d.ToString("dd.MM.yyyy HH:mm:ss"));
 +
</source>
 +
 +
==Opgave==

Revision as of 10:42, 20 November 2015

Hvis der skal gemmes en dato i C# kan det gøres i datatypen DateTime.


//Opret en DateTime med datoen 31/12-2015 Kl 22:25:05
DateTime d = new DateTime(2015, 12, 31, 22, 25, 05);

//Udskriv DateTime i formatet 
System.Console.WriteLine(d.ToString("dd.MM.yyyy HH:mm:ss"));

Opgave