Search code examples
c#.netobjecttypescasting

Is a Guid a primitive type or a complex type?


We separate out extension method classes by primitive types and complex types that we are extending. My question is simple. Would a Guid be considered a primitive type along with string, int, DateTime, etc? Or would it be considered a complex type when describing it?

Update

After reviewing the answers I much appreciate the clarification that I was able to glean from some answers. However, I am getting the impression that curiosity killed the cat got the cat murdered, so I am voting to close my own question.


Solution

  • It depends on what you call a "primitive data type".

    Wikipedia lists these two definitions:

    • a basic type is a data type provided by a programming language as a basic building block. Most languages allow more complicated composite types to be recursively constructed starting from basic types.
    • a built-in type is a data type for which the programming language provides built-in support.

    According to the first one, Guid is a constructed type, not a primitive.

    According to the second, it is also not a primitive type (as it is provided in the BCL, in the System namespace, and is not defined by any of the .NET languages).


    Update:

    This is what the IsPrimitive method of the Type class says:

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

    So, as far as .NET is concerned, it is not a primitive type.


    In conclusion: According to the three separate criteria above, Guid is definitely not a primitive type.