vb.netlistfind

Use of List.Find in 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?


Solution

  • 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")