Using Visual Basic // C#
I\'m trying to search through my stored arrays for a match to the user input. For example, the user has stored the data for a USB, and now wish
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 string
s.
In that case, you'd have to write:
if (ProductNameArray.Cast().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
method.
I'd personally prefer changing the method's signature, since the ProductNameArray
passed to it seems to really be a string[]
.