Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is DateTime a primitive type?

According to what I can find I believe DateTime is a primitive type but when I check my DateTime variable the property IsPrimitive is false.

7.3 Primitive Types (archive.org mirror)

In the article above you'll see that they say DateTime is primitive. So is there anything I'm doing wrong or have I read the article wrong?

like image 873
Gravinco Avatar asked Nov 05 '14 09:11

Gravinco


1 Answers

Date (which maps to System.DateTime) is a primitive type of the Visual Basic .NET language (VB.NET for short).

It's not a primitive type in C#, and it's not a primitive type in the CLR either.

A primitive type for a given language is a type for which you can write a string literal, and this literal is understood by the compiler to be of the relevant type. You can't do this for DateTime in C#.

A primitive type for the CLR is a type on which some low level optimizations are allowed. It's very restricted: only string and the different integer and floating-point numbers structs are primitive types.

like image 197
Falanwe Avatar answered Oct 14 '22 21:10

Falanwe