Я пытаюсь добавить новый список для каждого цикла в коде ниже в словарь, но в настоящее время я борюсь со следующей ошибкой:
не может преобразовать из 'void' в 'System.Collections.Generic.List
public class WeaponGen{
Dictionary<string, List<string>> weapons = new Dictionary <string, List<string>>();
public void WeaponGeneration(int GenerationCount)
{
Weapon weapon = new Weapon(); //this class contains basic calculation methods
weapons.Clear();
for (int i = 0; i < GenerationCount; i++)
{
string listname = "weapon" + i;
string id = Random.Range(1, 41).ToString();
List<string>[] _lists = new List<string>[GenerationCount];
_lists[i] = new List<string>();
weapons.Add(listname, _lists[i].Add(id)); //this line throws an error
weapons.Add(listname, _lists[i].Add(weapon.GetName(id))); //this line throws an error
weapons.Add(listname, _lists[i].Add(weapon.GetRarity(id))); //this line throws an error
weapons.Add(listname, _lists[i].Add(weapon.GetType(id))); //this line throws an error
weapons.Add(listname, _lists[i].Add(weapon.GetDmg(id).ToString())); //this line throws an error
weapons.Add(listname, _lists[i].Add(weapon.GetSpeed(id).ToString())); //this line throws an error
weapons.Add(listname, _lists[i].Add(weapon.GetCost(id).ToString())); //this line throws an error
}
}}
Поскольку в некоторых аспектах мне явно не хватает навыков кодирования, я подумал, что кто-то, кто лучше понимает язык, может мне помочь. Будем благодарны за любую помощь!