VB.NET谓词数组查找

时间:2008-12-15 09:08:13

标签: vb.net arrays find predicate

如何使用Array.Find将以下内容转换为VB.NET谓词?

Private Function FindCulture(ByVal Code As String) As Globalization.CultureInfo
    '
    Dim AllCultures As Globalization.CultureInfo() = Globalization.CultureInfo.GetCultures(Globalization.CultureTypes.AllCultures)
    '
    For Each Culture As Globalization.CultureInfo In AllCultures
        If Culture.TwoLetterISOLanguageName = Code Then
            Return Culture
        End If
    Next
    '
    Return Nothing
    '
End Function

1 个答案:

答案 0 :(得分:7)

Private Function FindCulture(ByVal Code As String) As Globalization.CultureInfo
    Dim AllCultures As Globalization.CultureInfo() = Globalization.CultureInfo.GetCultures(Globalization.CultureTypes.AllCultures)
    Return Array.Find(AllCultures, Function(s) s.TwoLetterISOLanguageName = Code)
End Function