In
Returns true if this string is any of the provided strings. Equivalent to IN operator in SQL. It eliminates the need to write something like 'if (foo == "foo1" || foo == "foo2" || foo == "foo3")'
Source
public static bool In(this string s, params string[] values)
{
return values.Any(x => x.Equals(s));
}
Example
if (product.Category.In("Electronics", "Computers")
{
// do something
}
©2007-2024 ExtensionMethod.NET.
ExtensionMethod.NET was built by Loek van den Ouweland and Fons Sonnemans
with ASP.NET Core, HTML, CSS, Javascript, SQL Server and some of the great methods you have posted here.
By using this website, you agree to the legal stuff .
We thank all who contributed to this website for the last twelve years. It really helped making this website a success!
Looking for Visual Studio Code Snippets? Visit our sister site VisualStudioCodeSnippets.com .