I have a string and an array of strings. I was wondering if it is possible to use an If statement in order to return a boolean value if the string contains a value from the array.
The code below doesn't work properly. Contains
can only take in one value as far as I can see. Is there a better way to do this without having to use a loop?
Dim FilePath As String = "C:\Users\Downloads\Test.jpg"
Dim GetExtension As String = FilePath.Substring(FilePath.Length - 3)
Dim FileExtensionArray() As String = {".png", ".jpg", ".tif"}
If GetExtension.Contains(FileExtension) = True Then
' Code
Else
' Code
End If
Aucun commentaire:
Enregistrer un commentaire