Click or drag to resize

StringUtilsSemiColonSearchList Method

Creates a semi-colon-separated list search string if the provided string is non-empty. If the provide string is null/empty then null is returned. The non-empty search string is forced to lower case using string.ToLowerInvariant(). The intended use of the search string is to allow for efficient membership testing where semi-colon wrapping prevents matching on partial values (e.g. finding "middle_name" when looking for "name" since ";name;" will not match on ";middle_name;").
Examples
The following example shows using SemiColonSearchList() to find a set fields by their keys.
C#
string  keysOfInterest = "name;first_name;last_name";  // But not, for example, "middle_name"
string  keys = StringUtils.SemiColonSearchList(keysOfInterest);

foreach (IField fld in mapper.Fields)
{
    if (keys != null && keys.Contains(";" + fld.Key.ToLowerInvariant() + ";"))  // Must test for null in case of empty search list.
    {
        items.Add(fld.Key);
    }
}

Namespace:  NetQuarry
Assembly:  EAP.Core (in EAP.Core.dll) Version: 2.0.0.0 (4.6.8.0)
Syntax
public static string SemiColonSearchList(
	string s
)

Parameters

s
Type: SystemString
The original semi-colon-separated list.

Return Value

Type: String
The search string, or null if the original string is null/empty.
See Also