I have a concurrent bag filled with strings like this:
var bag = new ConcurrentBag<string>();
The collection contains 100 strings from which I need to find a phrase like in following example:
"Galaxy S7" - search phrase
And lets say the titles are:
Samsung galaxy S4
Samsung galaxy S5
Samsung galaxy S6
Samsung galaxy S7
The output that I would get is:
Samsung galaxy S4
Samsung galaxy S5
Samsung galaxy S6
I've tried it with the method "Contains" that string has like following:
var _items = new ConcurrentBag<SearchItems>();
Parallel.For(0, xdoc.GetElementsByTagName("item").Count, index =>
{
if (negative != null && negative != "")
{
if (!xdoc.GetElementsByTagName("title").Item(index).InnerText.Contains(negative))
{
_items.Add(new SearchItems() {
CurrentPrice = Convert.ToDouble(xdoc.GetElementsByTagName("convertedCurrentPrice").Item(index).InnerText),
ItemID = xdoc.GetElementsByTagName("itemId").Item(index).InnerText,
Title = xdoc.GetElementsByTagName("title").Item(index).InnerText });
}
}
else
{
_items.Add(new SearchItems() {
CurrentPrice = Convert.ToDouble(xdoc.GetElementsByTagName("convertedCurrentPrice").Item(index).InnerText),
ItemID = xdoc.GetElementsByTagName("itemId").Item(index).InnerText,
Title = xdoc.GetElementsByTagName("title").Item(index).InnerText });
}
});
The problem is, contains is not case sensitive and if I try to exclude
s7
and
S7
I don't get same results... I need some solution that is not case sensitive :/
Can someone help me out?