2014-03-27 23 views
0

我有和數組,我想檢查我的Dim值是否包含在數組中,但我需要檢查它是否出現兩次。檢查數組中是否出現兩次值

例子:

Dim value as String = "AST" 

Dim zone_check_list() As String = {"AMST","AST","AST","EET","EDT"} 

'if "AST" appeared twice then i will show message box 
+0

你應該通過它通過一個循環.. –

回答

3

如何使用LINQ:

Imports System.Linq 

Dim value as String = "AST" 
Dim zone_check_list() As String = {"AMST","AST","AST","EET","EDT"} 
Dim isAppearTwice As Boolean = (zone_check_list.Count(Function(x) x = value) = 2) 
Console.WriteLine(isAppearTwice)