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;
}
所以在这里我正在循环Dictionary<string,bool> upgradesPurchased,我试图确保for循环是否在由行标记的最后一次迭代中if(i == upgradesPurchased.Count)我期望在这种情况下发生的情况是如果i等于字典中的项目数,那么字符串将在它的末尾收到一个“$”而不是一个“|” 然而似乎这条线被完全忽略了
摘要:我需要测试for循环是否在最后一次迭代中,如果是,则应将“$”添加到字符串中,如果不是“|” 应该添加到字符串中
潇潇雨雨
慕姐8265434
相关分类