gpt4 book ai didi

c# - 检查列表字符串为 null 或为空

转载 作者:行者123 更新时间:2023-12-04 13:07:15 25 4
gpt4 key购买 nike

这个问题在这里已经有了答案:





Check string is null or empty in linq

(3 个回答)


7年前关闭。




我有空的列表(“__”)

List<string> MyList = (List<string>)Session["MyList "];

if(MyList !=null || MyList != "")
{
}

如果字符串有更多空间,则 MyList != ""不起作用

如何通过在 c# 中使用 linq 来检查我的列表字符串是 ""还是 null?

最佳答案

if(MyList!=null || MyList.All(x=>string.IsNullOrWhiteSpace(x)))
{

}

关于c# - 检查列表字符串为 null 或为空,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19344754/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com