C# 关于 || 和 && 的问题 if (".txt.doc.xls.ppt.pdf".indexOf(fName)>=0){} 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 就针对这个例子而言,你可以把你的条件都装入HashSet里面,然后判断fName是否在其中。 if (fName == ".txt" || fName == ".doc" || fName == ".xls" || fName == ".ppt" || fName==".pdf"){}==?if((",.txt,.doc,.xls,.ppt,.pdf,").Contains(","+ fName +",")){} readonly IList<String> fNames = new List<String>() { ".doc", ".txt", ".xls", ".ppt", ".pdf" }; if(fNames.Contains(fName)){ // todo: } if (new string[] { ".doc", ".txt", ... }.Any(x => fNames == x)){ ...}如果是&&就用All string[] list = new string[]{"txt","doc","xls","ppt","pdf"};for(int i = list.length; i--;) if (fName == list[i]) { // TODE: 在这里写您的代码} 将后缀名放到一个集合中,判断fname是否在里面,以后需要加的话就往集合里面添加项就好了 wpf mvvm模式中怎么查找主程序datatemplate 中的用户控件呢? 用C#展现下面SQL语句的结果集,求C#源码! 请问开机动程序如何正确得到数据库文件路径? 字符串连接时循环运行速度慢,耗时,怎样解决!! 高手进来指点下 小弟在制作数码管取模软件时遇到了些问题 怎么验证URL地址的正确性??学习 for循环里面的arrKey[i]调用的是foreach的arrKey,这样写对吗, 请教高手,<>c__DisplayClass1 class2,报错不知道这个什么意思,请帮忙还原 winform问题,急! 请问有什么办法能将汉字替换成空? 关于vs中的引用
{
}==?if((",.txt,.doc,.xls,.ppt,.pdf,").Contains(","+ fName +",")){}
readonly IList<String> fNames = new List<String>() {
".doc",
".txt",
".xls",
".ppt",
".pdf"
}; if(fNames.Contains(fName)){
// todo:
}
{
...
}
如果是&&就用All
for(int i = list.length; i--;) if (fName == list[i]) {
// TODE: 在这里写您的代码
}