C# question on Comparing string arrays

Posted by Vijethamm under C# on 8/12/2014 | Points: 10 | Views : 491 | Status : [Member] | Replies : 1
Given a dictionary of words
And user entered word to compare against
When comparing the given word against the dictionary
Then output all words in the dictionary that exist in the given word

E.g. StartBurst would output Star and Burst if those words were in the dictionary.




Responses

Posted by: Kmandapalli on: 8/14/2014 [Member] Silver | Points: 25

Up
0
Down
Hi,

You can try with the following the following approach,

var array = new[] {"quick", "brown", "fox"};
var myString = "I love foxes.";
if (array.Any(s => myStr.IndexOf(s) >= 0)) {
// One of the elements is there
}

Mark as answer if satisfied..

Regards,
Kavya.

Kavya Shree Mandapalli

Vijethamm, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response