Computer Science, asked by nishitanagi5230, 1 year ago

system.Array' does not contain a definition for 'select'

Answers

Answered by Anonymous
0

You need using System.Linq; for that to work.

Any is an extension method defined in LINQ.

Also, pay attention to the type of ProductNameArray. If it is defined as Array (and not string[], for example), the compiler has no way of inferring that, when enumerated, it'll yield strings.

In that case, you'd have to write:

if (ProductNameArray.Cast<string>().Any(usersearch.Contains))

Edit: OK, looking at the code it seems that the problem is the one described above.

You'll have to change the signature of the FindProduct method from

static void FindProduct(Array ProductNameArray)

to

static void FindProduct(string[] ProductNameArray)

or use the .Cast<string> method.

I'd personally prefer changing the method's signature, since the ProductNameArray passed to it seems to really be a string[].

Similar questions