-1

I have an enum ENUMA in script A. I have a list of that enum in script A and also script B. I have a foreach loop in script C to compare those two lists, which I cannot get to work.

I get the following errors:

Using the generic type list requires 1 type arguments. GenericInventory.Itemtypes is a type, which is not valid. foreach statement cannot operate on variables of type bool.

I feel I have a core misunderstanding of enums but I am not sure what it is. More than the error itself, why is this occurring?

Script A

public enum ItemTypes
{
    Blank,

    Attack,
    Defend,
    Assist,
    Misc,

}

public List<ItemTypes> RequiredTypes = new List<ItemTypes>();

Script B

public List<ItemTypes> AllowedTypes = new List<ItemTypes>();

Script C

foreach (GenericInventory.ItemTypes type in List <GenericInventory.ItemTypes> itemsparent_inventory.RequiredTypes)
James
  • 69
  • 6
  • 3
    Try : foreach (GenericInventory.ItemTypes _type in itemsparent_inventory.RequiredTypes) – jdweng Jul 16 '19 at 11:49
  • Possible duplicate of [How do I enumerate an enum in C#?](https://stackoverflow.com/questions/105372/how-do-i-enumerate-an-enum-in-c) – Colin Young Jul 16 '19 at 12:17

1 Answers1

0

foreach (GenericInventory.ItemTypes _type in itemsparent_inventory.RequiredTypes) by jdweng was correct.

James
  • 69
  • 6