我有和数组,我想检查我的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)