myDictionary
appears to be a Dictionary<string, string>
type. Seeing as you store "Pokemon Name:"
and "name"
just fine one line above.
As such, you can just call hp.ToString()
to store it. Make sure to once again convert it back to int when using it though.
Alternatively, you can make a Dictionary<string, object>
storage to keep track of your information and simply cast the values when you retrieve them:
string name = (string)myDictionary["Pokemon Name:"];
int hp = (int)myDictionary["Pokemon HP:"];
solved Not sure what it wrong here and how to fix it [duplicate]