c# - unique LINQ to filter list by variables (case insensitive) -


i have

public int practice_example6 (list<car> cars) 

i want filter list make contains word "toyota" not filter case sensitive. other conditions suggestedretailprice should less 30000.

i think i'm there confused how handle case insensitive issue.

if (cars == null) {    return 0; } else {    list<car> filtered = cars.where(x => x.make == "honda").tolist();    list<car> filtered2 = cars.where(x => x.make == "honda").tolist();    list<car> filtered3 = cars.where(x => x.suggestedretailprice < 30000).tolist(); } 

i'm not sure on how return 3 variables (filtered1,2,3) in 1 return statement. perhaps combine 3 1 variable , return that?

i'm beginner , have researched this. appreciate explanations not fixes.

thanks!

edit: should not have without changing function ienumerable practice_example6(list cars) - know ideal there constraints imposed.

you can try:

string.equals(x.make, "honda", stringcomparison.currentcultureignorecase); 

so like:

list<car> filtered = cars.where(x => string.equals(x.make, "honda", stringcomparison.currentcultureignorecase)).tolist(); 

full method:

if (cars == null) {    return 0; } else {    return cars.count(x => string.equals(x.make, "honda", stringcomparison.currentcultureignorecase) && x.suggestedretailprice < 30000); } 

Comments

Popular posts from this blog

resizing Telegram inline keyboard -

command line - How can a Python program background itself? -

php - "cURL error 28: Resolving timed out" on Wordpress on Azure App Service on Linux -