Differences between select and selectmany

Source: Internet
Author: User

Both select () and selectmany () generate one or more result values based on the source values.

 

Select () generates a result value for each source value. Therefore, the overall result is a set with the same number of elements as the source set. In contrast, selectaggregate () generates a single overall result that contains a series subset from each source value. The conversion function passed as a parameter to selectcenters () must return a sequence of enumerated values for each source value. Then, select () concatenates these enumerated sequences to create a large sequence.

 

String [] Text = {"Albert was here ",
"Burke slept late ",
"Connor is happy "};

VaR tokens = text. Select (S => S. Split (''));

Foreach (string [] Line in tokens)
Foreach (string token in line)
Console. Write ("{0}.", token );

 

String [] Text = {"Albert was here ",
"Burke slept late ",
"Connor is happy "};

VaR tokens = text. selectiterator (S => S. Split (''));

Foreach (string token in tokens)
Console. Write ("{0}.", token );

 

 

The following two illustrations demonstrate the conceptual differences between the operations of the two methods. In each case, assume that the selector (conversion) function selects an array composed of flower data from each source value.

DescriptionSelect ()Returns a set with the same number of elements as the source set.

DescriptionSelectmany ()How to concatenate the intermediate array sequence into a final result value, which contains each value in each intermediate array.

 

Msdn: http://msdn.microsoft.com/zh-cn/library/bb546168.aspx#Mtps_DropDownFilterText

 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.