Possible Duplicate:
Check if a List already contains an item or not?
for (int i = 0; i < webSites.Count(); i++)
{
string t = webSites[i];
webCrawler(t, levels - 1);
// csFiles.add
}
MessageBox.Show(webSites.Count().ToString());
return csFiles;
Lets say in webSites i have:
Now in the second level lets say http://www.google.com exist again so this time i dont want to process it to do the recrusive if it will it will do it all over again the same thing. I need somehow to make or check that it will do each link once. How can i check it ?
I dont need to check just if the item already exist in the List i need to check if it was exist already so dont do it again since it will dig the same links again and repeat it self.
Create a temporary List and call it, let’s say, “temp”. Every iteration of the for loop, see if the string in that position in webSites is already in temp. If it is, ignore it. If it isn’t, add it to temp and then process it.
EDIT: Apparently this isn’t the best approach.