在线时间:8:00-16:00
迪恩网络APP
随时随地掌握行业动态
扫描二维码
关注迪恩网络微信公众号
public static class GuidExtentions { /// <summary> /// 根据GUID获取16位的唯一字符串 /// </summary> /// <param name="guid"></param> /// <returns></returns> public static string To16String(this Guid guid) { var i = guid.ToByteArray().Aggregate<byte, long>(1, (current, b) => current* (b + 1)); return $"{i - DateTime.Now.Ticks:x}"; } /// <summary> /// 根据GUID获取19位的唯一数字序列 /// </summary> /// <returns></returns> public static long ToInt64(this Guid guid) { var buffer = guid.ToByteArray(); return BitConverter.ToInt64(buffer, 0); } }
使用: var guid=Guid.NewGuid().To16String();
|
2023-10-27
2022-08-15
2022-08-17
2022-09-23
2022-08-13
请发表评论