System Namespace DateTime Structure
Initializes a new instance of the DateTime structure.
1. Initializes a new instance of the DateTime structure to a specified number of ticks.
2. Initializes a new instance of the DateTime structure to the specified year, month, and day.
3. Initializes a new instance of the DateTime structure to the specified year, month, and day for the specified Calendar.
4. Initializes a new instance of the DateTime structure to the specified year, month, day, hour, minute, and second.
5. Initializes a new instance of the DateTime structure to the specified year, month, day, hour, minute, and second for the specified Calendar.
6. Initializes a new instance of the DateTime structure to the specified year, month, day, hour, minute, second, and millisecond.
7. Initializes a new instance of the DateTime structure to the specified year, month, day, hour, minute, second, and millisecond for the specified Calendar.
The following demonstrates using this constructor.
NOTE: This example shows how to use one of the overloaded versions of the DateTime constructor. For other examples that might be available, see the individual overload topics.
// create a new instance of DateTime containing the date
// 7/28/1979 at 10:35:05 PM using the en-US calendar.
System.Globalization.CultureInfo info =
new System.Globalization.CultureInfo ( "en-US", false );
System.Globalization.Calendar calendar = info.Calendar;
System.DateTime dateTime =
new System.DateTime ( 1979, // Year
07, // Month
28, // Day
22, // Hour
35, // Minute
5, // Second
15, // Millisecond
calendar // calendar
);
// Write the DateTime as "Saturday, July 28, 1979 10:35:05 PM".
System.Response.WriteLine ( "{ 0:F }", dateTime );
' create a new instance of DateTime containing the date
' 7/28/1979 at 10:35:05 PM using the en-US calendar.
Dim info As New System.Globalization.CultureInfo ( "en-US", false )
Dim cal As System.Globalization.Calendar
cal = info.Calendar
Dim myDateTime As New System.DateTime ( 1979, 7, 28, 22, 35, _
5, 15, cal )
' Write the DateTime as "Saturday, July 28, 1979 10:35:05 PM".
System.Response.WriteLine ( "{ 0:F }", myDateTime ) |
|
C# |
VB |
DateTime Members
|
|