VB.NET Array Contains方法不起作用

Art*_*t F 4 vb.net asp.net arrays

在VB.NET中,我试图确定一个字符串数组中存在的给定字符串.根据我的研究,Array有一个我可以使用的'Contains'方法,所以Code看起来像这样:

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

If (fileTypesZ.Contains(tempTest)) Then

End If
Run Code Online (Sandbox Code Playgroud)

但是,VB.NET说'Contains'不是'System.Array'的成员.还有其他方法可供我使用吗?

Ree*_*sey 11

没有ContainsArray,但是Enumerable.Contains,这是一个扩展方法阵列上的作品.

确保包含Imports System.Linq在文件的顶部,以及您System.Core.dll在项目引用中引用的内容.