Cannot implicitly convert type `int'
Hello, so today i have an issue im trying to get my savemanager to save a garage that has been bought, i can now buy the garage but i cant save or load it when i click the play option i get one error
Assets/Scripts/SaveManager.cs(174,60): error CS0029: Cannot implicitly convert type int' to
System.Collections.Generic.List'
the error then takes me to this line
GameManager.Instance.Characters[0].OwnedGarages = (int)o[14];
i use Lists for the garages like this in gamemanager public List OwnedGarages = new List ();
can someone correct this ??
in save method i have SaveObjs.Add (GameManager.Instance.Characters [0].Cash); SaveObjs.Add (GameManager.Instance.Characters [1].Cash); SaveObjs.Add (GameManager.Instance.Characters [2].Cash);
and in the load method i have
GameManager.Instance.Characters[0].OwnedGarages = (int)o[14]; GameManager.Instance.Characters[1].OwnedGarages = (int)o [14]; GameManager.Instance.Characters[2].OwnedGarages = (int)o [15];
Answer by Jessespike · Apr 25, 2016 at 07:10 PM
Error says you cannot convert an int to a list.
The question doesn't specify what kind of list OwnedGarages is, or what "o" is. I'm going to assume it's a list of ints, in that case, why not add it to the list?
GameManager.Instance.Characters[0].OwnedGarages.Add(o[14]);
There seems to be some confusion with lists here. C# List Examples
this change bring Assets/Scripts/Save$$anonymous$$anager.cs(175,73): error CS0131: The left-hand side of an assignment must be a variable, a property or an indexer
also if i hover over o it says its Listo
also in gamemanager the OwnedGarage list is like this public List OwnedGarages = new List ();
and your line says Assets/Scripts/Save$$anonymous$$anager.cs(176,73): error CS1503: Argument #1' cannot convert
object' expression to type `Garage'
i miss spelt it but still dosnt solve the issue.
Your answer
![](https://koobas.hobune.stream/wayback/20220612075613im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
How to use the results of a dice roll? 2 Answers
How do i Instantiate sub-Points with in Multiple Points?? 0 Answers
OnGUI will not show up? 1 Answer
My audio doesn't play, I'm through my options... 1 Answer
VS Code or visual studio? 1 Answer