The code below shows the warning, with the “i” in “i++” underlined in Visual Studio. The code functions exactly as it should do, so I am not sure why I am getting this error. Is there anyway to fix this? If not, can I suppress the warning?
public static List<Ability> LoadExpertiseAbilityList(AbilityExpertise type)
{
List<Ability> temp = new List<Ability>();
for (int i = 0; i < abilityDatabase.Count; i++)
{
Ability a = abilityDatabase[i];
if (a.expertise == type)
temp.Add(a);
return temp;
}
return null;
}
Hi ItzChris92,
Out of interest, would you have got to the answer from just the first 2 responses on this thread alone?
I think that it will be valuable for you to become comfortable with debugging code through when confronted with issues where, for example, code is not acting as you expect.
I figured it out after your first comment… even though I had gone through the code line by line with the issue staring me in the face and I didn’t see it
I debug my code a lot, but I hadn’t thought to try to add more abilities to my database (I only have one currently, just setting the base for everything) as I thought the method was working correctly because it wasn’t returning null.
Appreciate the help guys. Stay tuned for more ridiculous overlooked mistakes on my part