我已经用linq查看了RegEx和SQLMatch,但我似乎无法找到适合我情况的规则.我想创造的将是......
//dataCollected[0] = { Name="joe", Url="http://my.home.site/" }
//dataCollected[N] = { Name="example", Url="http://german.home.site/" }
public bool hasParent(string test_url){
var obj = dataCollected.Where(s => ( test_url.contains(s.Url)));
return obj.Count() > 0;
}
bool result = hasParent("http://my.home.site/ShouldBeTrue"); //Finds http://my.home.site/
Run Code Online (Sandbox Code Playgroud)
你几乎就在那里,应该是另一种方式.另外,使用LINQ Any.如果找到任何匹配项,则返回true:
public bool hasParent(string test_url)
{
return dataCollected.Any(s => test_url.Contains(s.url));
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
159 次 |
| 最近记录: |