引用
using System;
帮助类代码
public static class GenerateIDHelp
{
/// <summary>
/// 生成当前时间字符串
/// </summary>
public static string GenerateTime
{
get
{
string id = DateTime.Now.ToString("yyyyMMddHHmmssfffffff");
return id;
}
}
/// <summary>
/// 创建时间+Guid的31位ID
/// </summary>
/// <returns></returns>
public static string GenerateId()
{
string id = GenerateTime;
string guid = Guid.NewGuid().ToString().Replace("-", "");
id += guid.Substring(0, 10);
return id;
}
}