The concat operator

1. What is the Concat operator?

2. What is the signature of the Concat operator?

The Concat operator concatenates two sequences.

 

public static IEnumerable<TSource> Concat<TSource>(

    this IEnumerable<TSource> first,

    IEnumerable<TSource> second);

 

Example 1:

 

            var italianCustomers = from c in Data.Customers

                                   where c.Country == Countries.Italy

                                   select c;

 

            var americanCustomers = from c in Data.Customers

                                    where c.Country == Countries.USA

                                    select c;

 

            var concatExpression = italianCustomers.Concat(americanCustomers);

          

            foreach (var item in concatExpression)

            {

                Trace.WriteLine(item);

            }

 

Output:

 

Paolo – Brescia – Italy

Marco – Torino – Italy

James – Dallas – USA

Frank – Seattle – USA

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s