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

ContainsAll

Check if the string contains all the elements in the array.

Source

public static bool ContainsAll(this String str, params String[] values)
{
    if (!String.IsNullOrEmpty(str) || values.Length > 0)
    {
        foreach (String value in values)
        {
            if (!str.Contains(value))
            {
                return false;
            }
        }
    }

    return true;
}

Example

String.ContainsAll(new String[] {"para1", "para2"});

Author: Jim

Submitted on: 29 aug. 2010

Language: C#

Type: System.String

Views: 4742