如何尝试将字符串转换为Guid [英] How to try convert a string to a Guid

查看:64
本文介绍了如何尝试将字符串转换为Guid的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我没有找到Guid的TryParse方法.我想知道其他人如何处理将字符串格式的GUID转换为GUID类型.

I did not find the TryParse method for the Guid. I’m wondering how others handle converting a guid in string format into a guid type.

Guid Id;
try
{
    Id = new Guid(Request.QueryString["id"]);
}
catch
{
    Id = Guid.Empty;
}

推荐答案

new Guid(string)

您还可以使用 TypeConverter 来查看.

这篇关于如何尝试将字符串转换为Guid的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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