I found a few solutions similar to my question but they are not helpful. I have an array list containing few string values { "Apple", "Banana", "AppleBanana" }
I want to be able to extract Apple from each string. Below is an extraction word "Apple". But how do I extract Apple from AppleBanana word?
string[] listOfString = { "Apple", "Banana", "Apple", "AppleBanana" };
var query = from string i in listOfString
group i by (i == "Apple") into appleString
select appleString;
foreach (var item in query)
{
if (item.Key == true)
{
string[] Applyby = item.ToArray();
foreach (var item2 in item)
{
Console.WriteLine(item2);
}
}
}
i == "Apple"usei.Contains("Apple"), in general, you can figure out this sort of stuff by reading the documentation or even by playing with intellisense in visual studio.Apple Appleyou don't want to find theAppleinAppleBanana. Can you explain the rules better?{ "Apple", "Banana", "Apple", "AppleBanana" }result in{ "Apple", "Apple" }or{ "Apple", "Apple", "Apple" }?