Search code examples
c#.netguidvalue-typereference-type

Is Guid considered a value type or reference type?


Guids are created using the new keyword which makes me think it's a reference type.

Is this correct?

Guid uid = new Guid();

Are Guids stored on the heap?


Solution

  • You can see the definition of a Guid yourself:

    public struct Guid ...
    

    Or you can test it like this:

    bool guidIsValueType = typeof(Guid).IsValueType;
    

    Quote: "GUID's are created using the new keyword which makes me think it's a reference type."

    Structs can have constructors too, for example new DateTime(2012, 12, 23).