This documentation is archived and is not being maintained.

Split(string, string)

This content is no longer actively maintained. It is provided as is, for anyone who may still be using these technologies, with no warranties or claims of accuracy with regard to the most recent product version or service release.

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), "@"))) { ... }
Show: