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

Raphe

Compare Strings like in SQL

Source

public static bool In(this string Value, params string[] ValuesToCompare)
{
bool IsIn = false;
foreach (string ValueToCompare in ValuesToCompare)
{
if (Value == ValueToCompare)
{
IsIn = true;
}
}
return IsIn;
}

Example

Console.Write("test".In("tes", "ew", "test")); // - true
Console.Write("test".In("tes", "ew")); // - false

Author: Raphe

Submitted on: 4 sep 2013

Language: C#

Type: String

Views: 3991