Is DateTime a primitive type?

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

http://msdn.microsoft.com/en-us/library/aa711900(v=vs.71).aspx

In the article above, you will see that they say DateTime is primitive. So what am I doing wrong or am I not reading the article incorrectly?

+3


source to share


3 answers


The MSDN page on IsPrimitive contains .net types that are considered primitive in relation to this method:

The primitive types are Boolean, Byte, SByte, Int16, UInt16, Int32, UInt32, Int64, UInt64, IntPtr, UIntPtr, Char, Double, and Single.



And DateTime is not on this list.

+3


source


Date

(which maps to System.DateTime

) is a primitive type of Visual Basic .NET (VB.NET for short).

It is not a primitive type in C # and it is not a primitive type in the CLR.



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

a primitive type for CLR is a type on which some low level optimizations are allowed. It is very limited: only string and different integers and numbers of numbers with number numbers are primitive types.

+4


source


Use Type.IsPrimitive to determine if a type is primitive.

For your specific question, you can try DateTime.Now.GetType().IsPrimitive

. (This returns false

). The link in the accepted answer is for the primitive types of the Visual Basic Language Specification ...

0


source







All Articles