c# - search my list help with linq -
i have
list<fruitobj> fruit fruitname, fruitcolor banana, yellow orange, orange cherry, red list<fruitobj> test = new list<fruitobj>();
is there inline way of searching list starts ban , return true if contain string?
bool hasban = test.any( x => x.fruitname.startswith("ban"));
note case sensitive, match "banana" do:
bool hasban = test.any( x => x.fruitname.startswith("ban", stringcomparison.invariantcultureignorecase));
Comments
Post a Comment