ExtensionMethod.NET Home of 880 C#, Visual Basic, F# and Javascript extension methods

In

Is Object in list

Source

<Extension()> _
Public Function [In](Of T)(ByVal Source As T, ByVal ParamArray List As T()) As Boolean
    For Each Value As T In List
        If Value.Equals(Source) Then
            Return True
        End If
    Next
    Return False
End Function

Example

Dim IsAdmin as boolean = UserName.ToLower.In("admin","administrator", "sysop")

Author: Rory Becker

Submitted on: 5 mrt. 2009

Language: VB

Type: System.Object

Views: 5021