Hi, I have a list of string, for example
List(4)
{
“ABC123.pdf”,
“DEF456.pdf”,
“GHI789.TXT”,
“JKL000.xls”
}
I want to check if the list is contain string DEF, and if it True, I want to get the whole value of that list item DEF456.pdf, but DEF can be lowercase or uppercase, so I have to ignore case sensitive, I want to use it in if, anyone can help? thank you
List = New List(Of String) From{
"ABC123.pdf",
"DEF456.pdf",
"GHI789.TXT",
"JKL000.xls"
}
result = List.FirstOrDefault(Function(x) x.ToLower().Contains("def"))
List = System.Collections.Generic.List(System.String)
Regards
1 Like
hey @Hendaryie_Tjoeng
try to use:
result = listOfFiles.FirstOrDefault(Function(item) item.ToUpper.Contains("DEF"))
1 Like
Try this
List.FirstOrDefault(Function(item) item.IndexOf("DEF", StringComparison.OrdinalIgnoreCase) >= 0)
Cheers!!