hey, this i have a loop that adds gathered strings and ints into an object, and then adds that object into a list. I need it to check if there is already an object with a property == to the one i'm about to assign, and then depending on which the property is, I either want to change one of its properties, or still add a new object. I'll be sorting this later. Here's where I'm stuck. I have marked the line (currently commented out) which when activated, causes the command line to freeze. The weird thing is that i use the IDENTICAL code earlier with no trouble.
As you can see, I have some other code currently commented out, as this bit needs to work before I can continue, but I left it in to allow you to get more of an idea of what i am doing.
solved. i actually had to move it another two loops upwards. THANKS!
//IF THIS IS THE FIRST ONE, ADD IT!
var refSize = Referrals.Count();
if (refSize == 0)
{
var NewReferral = new Referral(referringURL.Trim(), referringWords.Trim(), 3);
Referrals.Add(NewReferral);
}
else
{
for (int i=0;i<refSize;i++)
{
// RESET BOOLS
URLPresent = false;
KeywordPresent = false;
// IF THE URL IS ALREADY PRESENT
//if (Referrals[i].URL == referringURL)
//{
//URLPresent = true;
// CHECK IF THE KEYWORD IS ALREADY PRESENT
//for (int ii=0;ii<Referrals[i].Keywords.Count;ii++)
//{
// if (Referrals[i].Keywords[ii] == referringWords)
// {
// ADD TO OCCURRENCES
// Referrals[i].Occurrences++;
// KeywordPresent = true;
// }
//}
// ADD KEYWORD TO LIST
// ###
// ###
//}
// IF THE KEYWORD ISN'T THERE && THE URL ISNT THERE, ADD A NEW REFERRAL OBJECT
if (URLPresent == false && KeywordPresent == false)
{
var NewReferral = new Referral(referringURL.Trim(), referringWords.Trim(), 3);
//Referrals.Add(NewReferral); //HERE IS MY PROBLEM! UNCOMMENTING THIS LINE CAUSES A FAIL.
//URLPresent = true;
//KeywordPresent = true;
}
// IF THE URL IS THERE, BUT THE KEYWORD ISNT, ADD AN ELEMENT TO THE REFERRAL.KEYWORDS LIST
//else if (URLPresent == true && KeywordPresent == false)
//{
//Referrals[i].Keywords.Add(referringWords);
//URLPresent = true;
//KeywordPresent = true;
//}
}
}