Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why is there no built-in type for DateTime? [duplicate]

Tags:

c#

datetime

Most common datatypes have a built in type: Int32 has int, Boolean has bool, String has string, etc. Why is there no built-in type for DateTime?

First I thought it's because DateTime has properties and public functions, but so does int. Can anyone shed some light on this? What's the criteria for a type to have a built-in equivalent?

like image 450
MeanGreen Avatar asked Nov 17 '16 14:11

MeanGreen


1 Answers

The CLR only defines basic building blocks: the minimal data types necessary to define all others. Those are the types given an alias.

Since DateTime is just a collection of longs and integers, packed in a struct, there is no need to create a new data type in the CLR for it. You can build it with the data types already defined in the CLR. No need for aliasing it.

like image 177
Patrick Hofman Avatar answered Sep 27 '22 19:09

Patrick Hofman