String::Concat<T> Method (IEnumerable<T>^)

 
System_CAPS_noteNote

The .NET API Reference documentation has a new home. Visit the .NET API Browser on docs.microsoft.com to see the new experience.

Concatenates the members of an IEnumerable<T> implementation.

Namespace:   System
Assembly:  mscorlib (in mscorlib.dll)

public:
generic<typename T>
[ComVisibleAttribute(false)]
static String^ Concat(
	IEnumerable<T>^ values
)

Parameters

values
Type: System.Collections.Generic::IEnumerable<T>^

A collection object that implements the IEnumerable<T> interface.

Return Value

Type: System::String^

The concatenated members in values.

Type Parameters

T

The type of the members of values.

Exception Condition
ArgumentNullException

values is null.

The method concatenates each object in values; it does not add any delimiters.

An Empty string is used in place of any null argument.

Concat<T>(IEnumerable<T>^) is a convenience method that lets you concatenate each element in an IEnumerable<T> collection without first converting the elements to strings. It is particularly useful with Language-Integrated Query (LINQ) query expressions, as the example illustrates. The string representation of each object in the IEnumerable<T> collection is derived by calling that object's ToString method.

The following example defines a very simple Animal class that contains the name of an animal and the order to which it belongs. It then defines a List<T> object to contain a number of Animal objects. The Enumerable::Where<TSource> extension method is called to extract the Animal objects whose Order property equals "Rodent". The result is passed to the Concat<T>(IEnumerable<T>^) method and displayed to the console.

No code example is currently available or this language may not be supported.

Universal Windows Platform
Available since 8
.NET Framework
Available since 4.0
Portable Class Library
Supported in: portable .NET platforms
Silverlight
Available since 4.0
Windows Phone Silverlight
Available since 7.1
Windows Phone
Available since 8.1
Return to top
Show: