Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

VB.NET Array Contains method does not work

In VB.NET I am trying to determine in a given string exists in a String Array. According to my research the Array has a 'Contains' method that I can use, so the Code looks something like this:

Dim fileTypesZ As String() = {"PDF", "TXT", "DOC", "DOCX", "XLS", "XLSX", "JPG", "JPGE", "BMP", "GIF"}

If (fileTypesZ.Contains(tempTest)) Then

End If

However, VB.NET is saying 'Contains' is not a member of 'System.Array'. Is there another method that I can use?

like image 861
Art F Avatar asked Dec 11 '22 11:12

Art F


1 Answers

There is no Contains on Array, but there is Enumerable.Contains, which is an extension method that works on arrays.

Make sure to include Imports System.Linq at the top of your file, and that you're referencing System.Core.dll in your project references.

like image 104
Reed Copsey Avatar answered Dec 29 '22 12:12

Reed Copsey