Guid & GetHashCode uniqueness

后端 未结 5 1307
情话喂你
情话喂你 2020-12-06 04:37

Given the following key:

int key = Guid.NewGuid().GetHashCode();

Is this key unique as the uniqueness of Guid?

5条回答
  •  萌比男神i
    2020-12-06 05:03

    A Guid is a 128-bit number. An int is a 32-bit number, so it can't be "as unique" as the Guid.

    Besides, GetHashCode returns ... a hash code, it's not meant to be unique in any way. See other discussions here on SO about why GetHashCode() exists.

提交回复
热议问题