Logic/theory/function for a craft system.

Ok, so I coded a basic item, craft, and inventory script.
Here.

public class Inventory : MonoBehavior{

public List<Item> MyItems = new List<Item>();

void Craft(CraftRecipe r){
    //Check if the items in MyItems contains r.InputItems
bool b = CheckItems(r.InputItems);
if(b){
//I will write some code here later(I would not need help with destroying used items or adding the Output item)
}
}

    public bool CheckItems(List<Item> check){
//Check if MyItems contains check, and if so return true, else return false.
    }

}

public class Item{
public string MyName;
public string MyValue;
}
public class CraftRecipe{
public List<Item> InputItems = new List<Item>();
public Item Output;
}

Here’s the problem, how do I check if I have the Recipe’s input items in the inventory(I know I will use the CheckItems, but I do not know how to check if MyItems contains check), I do not use Linq, so anything using it would be nice if its explained.

Thanks!

For a neat LINQ way of doing it, this should work:

public bool CheckItems(List<Item> check) {
    return !check.Except(MyItems).Any();
}

See: Does .NET have a way to check if List a contains all items in List b? - Stack Overflow

Basically, Except() returns all of the items in the first enumerable (check) that aren’t also in the second (MyItems), then Any() returns true if there are any items in that set. In other words, if there are items in check that aren’t in MyItems, it returns true, then the inverse of that is returned by CheckItems().