为什么没有一个Guid.IsNullOrEmpty()方法 [英] Why isn't there a Guid.IsNullOrEmpty() method

查看:144
本文介绍了为什么没有一个Guid.IsNullOrEmpty()方法的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这让我想知道为什么的GUID .NET没有 IsNullOrEmpty()方法(其中空表示全0)

This keeps me wondering why Guid in .NET does not have IsNullOrEmpty() method (where empty means all zeros)

我写REST API时,需要这在我的ASP.NET MVC code几个地方。

I need this at several places in my ASP.NET MVC code when writing the REST API.

还是我失去了一些东西,因为在互联网上没有人要求一样吗?

Or am I missing something because nobody on the Internet has asked for the same?

推荐答案

的Guid 是值类型,所以键入的Guid 不能为空下手。如果你想知道它是一样的空GUID,你可以使用:

Guid is a value type, so a variable of type Guid can't be null to start with. If you want to know if it's the same as the empty guid, you can just use:

if (guid == Guid.Empty)

这篇关于为什么没有一个Guid.IsNullOrEmpty()方法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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