Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

VB.NET Predicate Array Find

How would I convert the following to a VB.NET predicate using Array.Find?

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
like image 240
Luke Avatar asked Dec 15 '08 09:12

Luke


1 Answers

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
like image 129
Darin Dimitrov Avatar answered Oct 17 '22 10:10

Darin Dimitrov