Linux 拨号vps windows公众号手机端

C#中怎么使用string.IsNullOrEmpty

lewis 6年前 (2019-11-23) 阅读数 6 #程序编程
文章标签 c#

在C#中,使用string.IsNullOrEmpty方法可以判断一个字符串是否为null或者为空字符串。示例如下:

string myString = "Hello World";

if (string.IsNullOrEmpty(myString))
{
    Console.WriteLine("String is null or empty");
}
else
{
    Console.WriteLine("String is not null or empty");
}

在上面的示例中,如果myString为空或者为null,则会输出"String is null or empty";否则会输出"String is not null or empty"。

版权声明

本文仅代表作者观点,不代表米安网络立场。

发表评论:

◎欢迎参与讨论,请在这里发表您的看法、交流您的观点。

热门