2种方法较为常见,一种直接通过new 转
Guid New_ShowCreateId = new Guid(ShowCreateId.ToString());
另一种
private static bool ToGuid(string string)
{
Match m = Regex.Match(str,@"^[0-9a-f]{8}(-[0-9a-f]{4}){3}-[0-9a-f]{12}$",RegexOptions.IgnoreCase);
Guid gv = new Guid();
if (m.Success)
{
gv = new Guid(string);
}
if (gv != Guid.Empty)
{
return true;
}
else
{
return false;
}
}