开发者

ASP.NET Try.Parse for Guids?

my application generates an uniqueidentifier in mssql which then used to generate a querystring for link for user to click. Page user lands after that click do something with user but first validates if such uniqueidentifier exists to avoid heavy stored procedure with small check. I want to improve it by checking whether querystring passed is actually a Guid.

My first question is whether .net Guid and MSSQL uniqueidentifier are of the same type and length and second one if there any better way to test whether some string is a Guid except

try { new Guid("somevalue") } catch (Except开发者_高级运维ion) {}


Answer to first question is, Yes they are the same.

2nd question, not that I'm aware of (Edit: Doh! TryParse), you could check the length and perhaps do some Regex but I'm not sure whether that would be more efficient or not.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜