从范围中寻找价值 [英] Finding value from range
本文介绍了从范围中寻找价值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
你好朋友,
我被困在寻找范围内的特定值时,说.
Hello friends,
I was bit stuck in finding out particular value in range, Say.
(121, 122, 123, 124, 125, 126, 127, 128, 129, 130, 131, 132, 133, 134, 135, 136, 137, 138, 139, 140, 141, 142, 143, 144, 145, 146, 147, 148, 149, 150, 151, 152, 153, 154, 155, 156, 157, 158, 159, 160, 161, 162, 163, 164, 165,166,167,177,178,185,188,189,190,191,193,197,198,199,213,214,215,223,224,228,229,230,231,240,241,244)
我已经在IF子句中尝试过
I have tried in IF clause
If dropdownlistChargingCategoryCreative1to3 in (121, 122, 123, 124, 125, 126, 127. . . .) then
End If
没有任何价值,对此有任何想法吗?
在此先感谢
not any worth, Any idea about it?
Thanks in advance
推荐答案
如果您的范围是逗号分隔的字符串,则可以采用多种方法,但是最好/最简单的方法是这样的:
If your range is a comma-delimited string, you could do it a number of ways, but the best/simplest would be something like this:
string myRange = "(121, 122, ..., 244)";
private bool InRange()
{
myRange = myRange.Replace(")","").Replace(")","");
string[] parts = myRange.Replace(" ", "").Split(',');
int count = (from part in parts
where part == dropdownlistChargingCategoryCreative1to3
select part).Count();
return (count > 0);
}
尝试链接 ^ ]
这篇关于从范围中寻找价值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文