Check if a list of strings contains a value

前端 未结 4 1160
后悔当初
后悔当初 2020-12-10 04:58

I have:

Public lsAuthors As List(Of String)

I want to add values to this list, but before adding I need to check if the exact value is alre

4条回答
  •  -上瘾入骨i
    2020-12-10 05:24

    You can get a list of matching items of your condition like this:

    Dim lsAuthors As List(Of String)
    
    Dim ResultData As String = lsAuthors.FirstOrDefault(Function(name) name.ToUpper().Contains(SearchFor.ToUpper()))
    If ResultData <> String.Empty Then
        ' Item found
    Else
        ' Item Not found
    End If
    

提交回复
热议问题