Is there any IN Operator in VB.net functions like the one in SQL

.net, operators, vb.net

Solution

Try using an array and then you can use the Contains extension:

Dim s() As String = {"Val1", "Val2", "Val3"}
If s.Contains(RoleName) Then
  'Go      
End If

Or without the declaration line:

If New String() {"Val1", "Val2", "Val3"}.Contains(RoleName) Then
  'Go
End If

From the OP, if the Contains extension is not available, you can try this:

If Array.IndexOf(New String() {"Val1", "Val2", "Val3"}, RoleName) > -1 Then
  'Go
End If

Problem

Is there any function or operator like: ``` If RoleName in ( "Val1", "Val2" ,"Val2" ) Then 'Go End If ``` Instead of: ``` If RoleName = "Val1" Or RoleName = "Val2" Or RoleName = "Val2" Then 'Go End If ```

Original source