consider the following example:
public IEnumerable<String> Test ()
{
IEnumerable<String> lexicalStrings = new List<String> { "test", "t" };
IEnumerable<String> allLexicals = new List<String> { "test", "Test", "T", "t" };
IEnumerable<String> lexicals = new List<String> ();
foreach (String s in lexicalStrings)
lexicals = lexicals.Union (allLexicals.Where (lexical => lexical == s));
return lexicals;
}
I was hoping he would produce "test", "t" as the output, but he would not (the output would be only "t"). I'm not sure, but you might have to do something with deferred processing. Any ideas how to make this work or use a good alternative?
Edit: Please note that this is just a simplified example. lexicalStringsand allLexicals- these are different types in the source code. Therefore, I cannot directly combine them.
Edit2 problem for solution looks something like this:
public IEnumerable<Lexical> Test ()
{
IEnumerable<String> lexicalStrings = new List<String> { "test", "t" };
IEnumerable<Lexical> allLexicals = new List<Lexical> { ... };
IEnumerable<Lexical> lexicals = new List<Lexical> ();
foreach (String s in lexicalStrings)
lexicals = lexicals.Union (allLexicals.Where (lexical => lexical.Text == s));
return lexicals;
}
source
share