example please of how to use Array.Exists method

T

Tim

Dim Animals as String() = {"cat", "dog", "mouse", "rat"}

Can the Exists or Find method be used to determine if the Animals array
contains "mouse" ?

If Animals.Exists(....

or

Animals.Find(...

I get a compiler error: Type argument inferred from the argument passed
to parameter 'match'conflicts with the type argument inferred from the
argument passed to parameter 'array'.

Thanks
Tim
 
?

=?ISO-8859-1?Q?G=F6ran_Andersson?=

Tim said:
Dim Animals as String() = {"cat", "dog", "mouse", "rat"}

Can the Exists or Find method be used to determine if the Animals array
contains "mouse" ?

If Animals.Exists(....

or

Animals.Find(...

The methods can be used for that, but not that way. The Exists and Find
method are static, so it would be:

found = Array.Exists(Animals, ... )

and

animal = Array.Find(Animals, ... )
I get a compiler error: Type argument inferred from the argument passed
to parameter 'match'conflicts with the type argument inferred from the
argument passed to parameter 'array'.

That means that the type of the array doesn't match the argument in your
predicate. If you show a bit of the code, someone might be able to help
you with it.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top