Legend

Class
Struct
Enum
Interface
Delegate
Constructor
Method
Property
Event
Field

Extension method: string JoinString<T>(this IEnumerable<T>, string, string, string, string)

Declaration

public static string JoinString<T>(
    this IEnumerable<T> values,
    string separator = null,
    string prefix = null,
    string suffix = null,
    string lastSeparator = null
)

Summary

Turns all elements in the enumerable to strings and joins them using the specified separator and the specified prefix and suffix for each string.

Generic type parameters

TThis type parameter is not documented.

Parameters

this IEnumerable<T>values The sequence of elements to join into a string.
stringseparator Optionally, a separator to insert between each element and the next.
stringprefix Optionally, a string to insert in front of each element.
stringsuffix Optionally, a string to insert after each element.
stringlastSeparator Optionally, a separator to use between the second-to-last and the last element.

Example

// Returns "[Paris], [London], [Tokyo]"
(new[] { "Paris", "London", "Tokyo" }).JoinString(", ", "[", "]")

// Returns "[Paris], [London] and [Tokyo]"
(new[] { "Paris", "London", "Tokyo" }).JoinString(", ", "[", "]", " and ");