ABID KHAN
ABID KHAN

Reputation: 35

How to convert GUID to int32?

I have the following GUID 0d9fc5f5-f2f2-477c-a876-a6ece127ea60

Is there an only tool converter. Or Can I use some C# lib to do the conversion

Upvotes: 1

Views: 3659

Answers (1)

jods
jods

Reputation: 4591

No idea what you're trying to achieve but here you go:

int x = new Guid("0d9fc5f5-f2f2-477c-a876-a6ece127ea60").GetHashCode();

Collisions are possible and you can't avoid it, since a GUID contains 128 bits and a int only 32. (see pigeon hole principle).

Is x related to the Guid in any way? no. Again, not sure what you're trying to achieve, the code above is really not very different from generating a random 32 bits number.

Upvotes: 2

Related Questions