VB.NET Array包含方法不起作用 [英] VB.NET Array Contains method does not work
问题描述
在VB.NET我试图确定在一个字符串数组存在一个给定的字符串。根据我的研究阵中拥有'包含',我可以使用的方法,所以code看起来是这样的:
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
然而,VB.NET是说'包含'不'的System.Array的成员。有没有我可以使用另一种方法?
However, VB.NET is saying 'Contains' is not a member of 'System.Array'. Is there another method that I can use?
推荐答案
有没有包含
在阵列
,但有<一个href=\"http://msdn.microsoft.com/en-us/library/system.linq.enumerable.contains.aspx\"><$c$c>Enumerable.Contains$c$c>,这是一个扩展方法对数组的作品。
There is no Contains
on Array
, but there is Enumerable.Contains
, which is an extension method that works on arrays.
请确保包括进口System.Linq的
你的文件的顶部,而你引用 System.Core.dll
在您的项目引用。
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.
这篇关于VB.NET Array包含方法不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!