Skip to content

Comparing the 1st and 2nd overload of LINQ 'SelectMany' with LINQ Query Syntax.

Notifications You must be signed in to change notification settings

reiugit/LinqSelectManyExample

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

30 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Comparing LINQ Query Syntax with the
1st and 2nd overload of LINQ 'SelectMany'

Example of getting all variations of 3 characters from 3 strings using LINQ:

  1. with LINQ query syntax
  from x in "ABC"
  from y in "123"
  from z in "123"
  select $"{x}{y}{z} ");
  1. with LINQ method syntax, using the 1st overload of 'SelectMany'
    (only with collection selector, this needs an additional nested select)
  "ABC".SelectMany(x => "123".Select(y => $"{x}{y}"))
       .SelectMany(x => "123".Select(y => $"{x}{y} ")));
  1. with LINQ method syntax, using the 2nd overload of 'SelectMany'
    (with collection selector and result selector)
  "ABC".SelectMany(x => "123", (x, y) => $"{x}{y}")
       .SelectMany(x => "123", (x, y) => $"{x}{y} "));

About

Comparing the 1st and 2nd overload of LINQ 'SelectMany' with LINQ Query Syntax.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages