Share via


Split(string, string)

Applies to: Lync 2013 | Lync Server 2013

Split(string, string)

The Split(string, string) function splits a string on a specified separator character and returns a string collection.

Syntax

collection<string> Split(
  string source,
  string separator
);

Parameters

  • source
    The string to split.

  • separator
    A single-character string at which the source string is split. If separator consists of more than one character, only the first character is used and the function returns a separate element in the collection for each occurrence of this character, even if multiple occurrences of this character are adjacent to one another. If an empty string is passed in, then the separator character is a comma.

Return values

Returns a collection of string values. Use the foreach keyword to iterate through the collection. If the separator string is not found, this function returns the original source string value as the single element in the collection.

Example code

The following code example splits a URI on the "@" (at) symbol, returning the username as the first element in the collection and the hostname as the second.

foreach (userAndHost in Split(GetUri(sipRequest.From), "@"))) { ... }