Witam,
w pewnej książce do c# znalazłem coś takiego:
public IEnumerable<Enemy> Enemies {get; private set; }
private void NewLevel(Random random)
{
level++;
switch(level)
{
case 1:
Enemies = new List<Enemy>();
Enemies.Add(new Bat(this, GetRandomLocation(random)));
WeaponInRoom = new Sword(this, GetRandomLocation(random));
break;
}
}
Problem w tym, że dostaję error:
'IEnumerable<Enemy>' does not contain a definition for 'Add' and no extension method 'Add' accepting a first argument of type 'IEnumerable<Enemy>' could be found (are you missing a using directive or an assembly reference?)
Czy to faktycznie błąd, że zamiast List<Enemy> napisali IEnumerable, czy da się to jednak jakoś zrobić?