I have a list of foo called crepes. I want to return foo where bar.doritos == "coolRanch"
class foo
{
List<bar> item;
string candy;
string beer;
}
class bar
{
string doritos;
string usb;
}
var item = crepes.item.Where(x => x.doritos == "coolRanch").FirstOrDefault();
From other threads, i've pieced together the above linq query, but crepes.item throws an error. "List does not contain a definition for 'item' and no definition for 'item' accepting first argument...
C#
are private by default. Change your declaration topublic List<bar> item;