We help IT Professionals succeed at work.

VB.NET - Array.Find

feesu
feesu asked
on
10,718 Views
Last Modified: 2013-11-26
Experts,
I needed to search inside an array instead of looping like i used to do in vb6. I looked into the msdn and found this example. But i'm unable to use it. How do i use it? I keep getting errors on the "T"

...
Visual Basic (Declaration)
Public Shared Function Find(Of T) ( _
      array As T(), _
      match As Predicate(Of T) _
) As T
Visual Basic (Usage)
Dim array As T()
Dim match As Predicate(Of T)
Dim returnValue As T

returnValue = Array.Find(array, match)
Comment
Watch Question

Dirk HaestProject manager
CERTIFIED EXPERT

Commented:
Can you show the declaration of your array ? What do you keep in your array.

See example of implementation of generic function you give
http://msdn2.microsoft.com/en-us/library/d9hy2xwa(VS.80).aspx

Author

Commented:
I have an array of integers and i need to look in it for a certain value. I've not yet done any code on it.
The example you sent is the one i pasted above!

Where should i keep the declaration part to be able to start using the function?
Commented:
This one is on us!
(Get your first solution completely free - no credit card required)
UNLOCK SOLUTION
Dirk HaestProject manager
CERTIFIED EXPERT

Commented:
By the way, you'll need to implement your own find (and that only will be possible with a loop :))
For more information about generics: http://msdn2.microsoft.com/en-us/library/aa479866.aspx#netframework_topic13
Unlock the solution to this question.
Join our community and discover your potential

Experts Exchange is the only place where you can interact directly with leading experts in the technology field. Become a member today and access the collective knowledge of thousands of technology experts.

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

OR

Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.