Is Guid considered a value type or reference type?

前端 未结 6 1333
-上瘾入骨i
-上瘾入骨i 2021-01-03 18:32

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

Is this correct?

Guid uid = new Guid();

<
6条回答
  •  天命终不由人
    2021-01-03 18:57

    You can see the definition of a Guid yourself:

    public struct Guid ...
    

    Or you can test it like this:

    bool guidIsValueType = typeof(Guid).IsValueType;
    

    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).

提交回复
热议问题