Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Use of List.Find in VB.NET

Tags:

find

list

vb.net

I have two columns. One column contains string values and another column contains decimal values. I want to select the decimal value by selecting the string value.

string          decimal
Jewel           10
Hasan           20

How do I select Jewel so it will return 10?

like image 243
Syed Md. Kamruzzaman Avatar asked Feb 04 '13 06:02

Syed Md. Kamruzzaman


People also ask

What is list in VB net?

The List class is used to store generic types of collections objects. By using a generic class on the list, we can store one type of object. The List size can be dynamically different depending on the need of the application, such as adding, searching or inserting elements into a list.

How do you check an item exists in list in VB net?

By using Contains() method, we can check whether the specified element exists in the list or not. In case, if it exists it will return True otherwise False.

Where is predicate in VB net?

A Predicate is a function object that receives arguments, and always returns a Boolean. It tells us whether something is true or false. Here We see 2 Predicates. The first tells us whether an integer is positive—it returns True if the value is greater than or equal to 0.


1 Answers

Try this:

Dim selectedValues As List(Of InvoiceSOA)
selectedValues = DisputeList.FindAll(Function(p) p.ColumnName = "Jewel")

Or, if you need the first occurence of "Jewel" use this:

Dim selectedValue As InvoiceSOA
selectedValue = DisputeList.Find(Function(p) p.ColumnName = "Jewel")
like image 91
Andrey Gordeev Avatar answered Sep 20 '22 03:09

Andrey Gordeev