locked
How to find item in System.Collections.Generic.List by a value RRS feed

  • Question

  • User-785021171 posted

    Hello,

    I have the following situation:

    Public Class ePrice
    Public PriceID As Integer
    Public
    InternalPrice As Single
    Public
    OriginalSellPrice As Single
    Public
    ActualSellPrice As Single
    Public
    CurrencyCultureCode As String
    End Class


    Public Class
    eItem
    Dim myPriceCollection As System.Collections.Generic.List(Of ePrice)

    Public Property PriceCollection() As System.Collections.Generic.List(Of ePrice)
    Get
    Return
    myPriceCollection
    End Get
    Set
    (ByVal value As System.Collections.Generic.List(Of ePrice))
    myPriceCollection = value
    End Set
    End Property
    End Class
     

    I need to find the ePrice item with a specific CurrencyCultureCode in the PriceCollection.

    I can find the item using an index like this

    Dim objCatalogItem As New eItem
    Dim objPrice As New ePrice
    objPrice = CatalogItem.PriceCollection.Item(1)

    but I don't know how to find the item using Find method...
    objPrice = CatalogItem.PriceCollection.Find(........) 


    Can you please help me with that?
    Thanks for any help!

    Radoslav


     

    Thursday, May 8, 2008 2:49 PM

Answers

  • User-1995538749 posted

    If you're using 3.5, then use a Lambda Expression like so:

    objCatalogItem.PriceCollection.Find(Function(p) p.CurrencyCultureCode = MyCurrencyCultureCode)

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Thursday, May 8, 2008 3:20 PM

All replies

  • User-1995538749 posted

    If you're using 3.5, then use a Lambda Expression like so:

    objCatalogItem.PriceCollection.Find(Function(p) p.CurrencyCultureCode = MyCurrencyCultureCode)

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Thursday, May 8, 2008 3:20 PM
  • User-785021171 posted

    Works fine!

    Thanks a lot,
    Radoslav


     

    Thursday, May 8, 2008 4:30 PM