【发布时间】:2018-01-11 00:00:50
【问题描述】:
我有以下if 条件:
if (!string.IsNullOrEmpty(str) &&
(!str.ToLower().Contains("getmedia") && !str.ToLower().Contains("cmsscripts") &&
!str.ToLower().Contains("cmspages") && !str.ToLower().Contains("asmx") &&
!str.ToLower().Contains("cmsadmincontrols"))
)
我正在尝试创建一个关键字数组,而不是放置多个 AND 条件,您能帮忙吗?
string[] excludeUrlKeyword = ConfigurationManager.AppSettings["ExcludeUrlKeyword"].Split(',');
for (int i = 0; i < excludeUrlKeyword.Length; i++)
{
var sExcludeUrlKeyword = excludeUrlKeyword[i];
}
如何从数组中构建相同的 if 条件?
【问题讨论】:
-
使用 LinQ 任意或全部
-
我们可以在没有 LINQ 的情况下编写代码吗?
标签: c# asp.net .net arrays for-loop