If the ingredients of a pizza exist among allIngred, the result would give true by using LINQ. How would I go about doing this?
string[] allIngred = {
"oil", "yeast", "wheat-flour", "salt", "oil", "baking-powder",
"wheat-flour", "salt", "sugar", "milk"
};
string[] pizza = { "oil", "yeast", "wheat-flour", "salt" };
You can use a combination of the All and Contains methods to check that all items in pizza exist in allIngred:
bool result = pizza.All(i => allIngred.Contains(i));
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With