C# String Concat(IEnumerable)
Description
String Concat
concatenates
the members of an IEnumerable
Syntax
String.Concat<T>(IEnumerable<T>)
has the following syntax.
[ComVisibleAttribute(false)]
public static string Concat<T>(
IEnumerable<T> values
)
Parameters
String.Concat<T>(IEnumerable<T>)
has the following parameters.
T
- The type of the members of values.values
- A collection object that implements the IEnumerableinterface.
Returns
String.Concat<T>(IEnumerable<T>)
method returns The concatenated members in values.
Example
The following code shows how to use
String.Concat<T>(IEnumerable<T>)
method.
using System;/*w w w .jav a2 s . co m*/
using System.Collections.Generic;
using System.Linq;
public class Animal
{
public string Kind;
public string Order;
public Animal(string kind, string order)
{
this.Kind = kind;
this.Order = order;
}
public override string ToString()
{
return this.Kind;
}
}
public class Example
{
public static void Main()
{
List<Animal> animals = new List<Animal>();
animals.Add(new Animal("Squirrel", "Rodent"));
animals.Add(new Animal("Gray Wolf", "Carnivora"));
string output = String.Concat(animals.Where( animal =>
(animal.Order == "Rodent")));
Console.WriteLine(output);
}
}
The code above generates the following result.