如何在 PowerShell 中检查字符串是否为 null 或为空? [英] How can I check if a string is null or empty in PowerShell?

查看:86
本文介绍了如何在 PowerShell 中检查字符串是否为 null 或为空?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在 PowerShell 中是否有类似 IsNullOrEmpty 的内置函数来检查字符串是 null 还是空?

Is there a built-in IsNullOrEmpty-like function in order to check if a string is null or empty, in PowerShell?

到目前为止我找不到它,如果有内置方式,我不想为此编写函数.

I could not find it so far and if there is a built-in way, I do not want to write a function for this.

推荐答案

您可以使用 IsNullOrEmpty 静态方法:

You can use the IsNullOrEmpty static method:

[string]::IsNullOrEmpty(...)

这篇关于如何在 PowerShell 中检查字符串是否为 null 或为空?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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