List<string> list = project.Lists["list"].ToList<string>();
// add demo data list
list.Add( "line1");
list.Add( "line2");
List<string> list1 = project.Lists["list1"].ToList<string>();
// add demo data list1
list1.Add( "e1");
list1.Add( "e2");
IZennoList list4 = project.Lists["l4"]; // list result
foreach (string s1 in list) {
foreach (string s2 in list1) {
if (s1.Contains(s2)) list4.Add(s1);
}
}
Посмотреть вложение 92497
Don't work properly, maybe it's happen cause list have 10k string?
Apparently I misunderstood the problem.
You wrote that the code does not run correctly in Zennoposter, but it does work well in Visual Studio.
I took your code, inserted the demo data and see that the code is executed correctly, as it should be executed - it checks if there is a substring from the second list in the line from the first list, and if it finds one, then it adds to the third list the line in which the check for the presence of a string from the second list.
Probably Google translator will distort the context of my message.
If your problem persists, try to describe in more detail what exactly you want the code to do.
So, in digits:
I have 'emails' and 'domains' name lists. 'Emails' list much more than second one. I would like to add string to new list if current string in 'emails' list contain in 'domains', in other words, if domain exist in emails - allow to adding these emails with this domain to new list.
Sample:
emails list:
[email protected]
[email protected]
[email protected]
domains list:
zennolab.com
gmail.com
result list:
[email protected]
[email protected]
With your sample, it works, but If i comment strings with 'list.add' result list is empty, if I added 2 records like in your sample it works and I get 22 other emails, but must be something much more, in this case, cause my 'domains' list have much more strings than 22, and 'emails' have this domains, previosly it was a one list before separate with regex '(?<=@).*'
Sorry that steal your time with disinformation earlier.
Idea in pseudocode:
foreach (string email in emails) {
foreach (string domain in domains) {
if (email.Contains(domain)) result.Add(email);
}
}
I was learning other variants, founnd method .Find but can't implement him in zenno