C# DateTime DateTime(Int32, Int32, Int32)
Description
DateTime DateTime(Int32, Int32, Int32)
initializes
a new instance of the DateTime structure to the specified year, month, and
day.
Syntax
DateTime.DateTime(Int32, Int32, Int32)
has the following syntax.
public DateTime(/*w w w . ja va 2 s . c o m*/
int year,
int month,
int day
)
Parameters
DateTime.DateTime(Int32, Int32, Int32)
has the following parameters.
year
- The year (1 through 9999).month
- The month (1 through 12).day
- The day (1 through the number of days in month).
Example
The following example uses the DateTime(Int32, Int32, Int32) constructor to instantiate a DateTime value.
The example also illustrates that this overload creates a DateTime value whose time component equals midnight (or 0:00).
using System;//w w w . j a v a2s. c o m
public class MainClass{
public static void Main(String[] argv){
DateTime date1 = new DateTime(2010, 8, 18);
System.Console.WriteLine(date1.ToString());
}
}
The code above generates the following result.