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

In

Strongly typed code version of the common IN clause for SQL.

Source

Public Function [In](Of T)(ByVal objCompareFrom As T, ByVal ParamArray objCompareTo As T()) As Boolean
  For Each compareToSingle As T In objCompareTo
    If objCompareFrom.Equals(compareToSingle) Then _
      Return True
  Next
  Return False
End Function

Example

If myName.In("Ryan","Todd","Brian") Then _
  DoMyFunction()

If currentClient.In(firstClient,secondClient,thirdClient) Then _
  DoMyFunction()

Author: Brian Wigfield

Submitted on: 15 okt 2010

Language: VB

Type: System.Object<T>

Views: 2467