Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Linq expression to filter formcollection

Tags:

c#

asp.net

linq

I have a FormCollection and I just want to only iterate through the keys the do not contain the string pricing.

So what I tried was this...

foreach (var key in collection.AllKeys.Where(k => !k.Contains("Pricing"))){ ... }

The problem is the return is not a filtered list its returning boolean values... in which in need the filtered list of string...

AllKeys returns a string[] so in a sense I am just trying to filter a string[] here...

What I am missing here...

Thanks much!

like image 721
Gabe Avatar asked Nov 06 '09 16:11

Gabe


1 Answers

Here is the answer...

foreach (var key in collection.AllKeys.Where(k => !k.Contains("Pricing")).ToArray<string>()){ ... }
like image 113
Gabe Avatar answered Oct 23 '22 01:10

Gabe