怎么把Long转换成Guid and Vice Versa? [英] How to Convert Long to Guid and Vice Versa?

查看:227
本文介绍了怎么把Long转换成Guid and Vice Versa?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这甚至有可能吗?我什至不认为是这样,但是我看到了一些试图做到这一点的代码.但是,我的单元测试表明它无法正常工作.我确实看到了一些类似的想法:

Is this even possible? I don't even think it is, but I saw some code that was trying to do it. However, my unit tests showed that it was not working. I did see some similar thoughts:

  • Converting GUID to Integer and Back
  • Converting System.Decimal to System.Guid

只是为了澄清. Guid的创作超出了我的控制范围;因此,我不能只将值存储在其中一组Guid中.

Just for clarification. The Guid creation is outside of my control; therefore, I can't just store the value in one of the Guid sets.

推荐答案

GUID的长度为16个字节.通常将长"理解为64位(即8字节)长.您不能在不丢失或提供额外数据的情况下在两者之间进行转换.

A GUID is 16 bytes long. A "long" is often understood as being 64 bits (i.e. 8 bytes) long. You cannot convert between those without losing or providing extra data.

这篇关于怎么把Long转换成Guid and Vice Versa?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆