public string GetUpgradesPurchasedVal()
{
string upgradesPurchasedVals = "";
for (int i = 0; i < upgradesPurchased.Count; i++) {
if (i == upgradesPurchased.Count) {
upgradesPurchasedVals += upgradesPurchased [upgradeNames[i]].ToString () + "$";
} else {
upgradesPurchasedVals += upgradesPurchased [upgradeNames[i]].ToString () + "|";
}
}
return upgradesPurchasedVals;
}
So here I am looping through the Dictionary<string,bool> upgradesPurchased
and I am trying to make sure if the for
loop is at the last iteration marked by the line if(i == upgradesPurchased.Count)
what I expected to happen in this case is if i
is equal to the number of items in the dictionary then the string would receive a "$" at the end of it instead of a "|" however it would seem that the line is ignored altogether
Summary: I need to test if the for
loop is at the last iteration if so then "$" should be added to the string if not "|" should be added to the string