How to find whether a string array contains some part of string?
I have array like this
String[] stringArray = new [] { "abc@gmail.com", "cde@yahoo.com", "@gmail.com" };
string str = "coure06@gmail.com"
if (stringArray.Any(x => x.Contains(str)))
{
//this if condition is never true
}
i want to run this if block when str contains a string thats completely or part of any of array’s Item.
Assuming you’ve got LINQ available:
Even without LINQ it’s easy:
or using C# 2:
If you’re using C# 1 then you probably have to do it the hard way 🙂