or
or
By clicking below, you agree to our terms of service.
New to HackMD? Sign up
Syntax | Example | Reference | |
---|---|---|---|
# Header | Header | 基本排版 | |
- Unordered List |
|
||
1. Ordered List |
|
||
- [ ] Todo List |
|
||
> Blockquote | Blockquote |
||
**Bold font** | Bold font | ||
*Italics font* | Italics font | ||
~~Strikethrough~~ | |||
19^th^ | 19th | ||
H~2~O | H2O | ||
++Inserted text++ | Inserted text | ||
==Marked text== | Marked text | ||
[link text](https:// "title") | Link | ||
 | Image | ||
`Code` | Code |
在筆記中貼入程式碼 | |
```javascript var i = 0; ``` |
|
||
:smile: | ![]() |
Emoji list | |
{%youtube youtube_id %} | Externals | ||
$L^aT_eX$ | LaTeX | ||
:::info This is a alert area. ::: |
This is a alert area. |
On a scale of 0-10, how likely is it that you would recommend HackMD to your friends, family or business associates?
Please give us some advice and help us improve HackMD.
Syncing
xxxxxxxxxx
Projection Operators - SelectMany
SelectMany 的功用與 Select 相同 , 都是依照我們設定的委派去對資料源做出處理 , 並輸出. 但是差異是 Select 只取得第一層的查詢結果放到輸出序列中 , 但是 SelectMany 若發現查詢結果回傳的是一個可以列舉的序列 , 則會再進一步把這個序列中的項目取出來 , 放到輸出序列中 , 也就是用 SelectMany 運算子 , 查詢出來的輸出序列之深度會比 Select 少一層. SelectMany 通常是在處理巢狀集合的時候使用 , 可以替我們省去多層迴圈 .
一言以蔽之 , SelectMany 可以將集合中每個元素內的子集合合併為一個新的集合. 換句話說 , SelectMany 可以幫我們把子集合展開成一個.
使用時機
你喜歡跑雙層迴圈取值 , 那這個函數可以當作沒看到
- The image file may be corrupted
- The server hosting the image is unavailable
- The image path is incorrect
- The image format is not supported
Learn More →多載形式
SelectMany<TSource,TResult>(this IEnumerable<TSource>, Func<TSource,IEnumerable<TResult>>)
SelectMany<TSource,TResult>(this IEnumerable<TSource>, Func<TSource,Int32,IEnumerable<TResult>>)
SelectMany<TSource,TCollection,TResult>(this IEnumerable<TSource>, Func<TSource,IEnumerable<TCollection>>, Func<TSource,TCollection,TResult>)
SelectMany<TSource,TCollection,TResult>(this IEnumerable<TSource>, Func<TSource,Int32,IEnumerable<TCollection>>, Func<TSource,TCollection,TResult>)
解釋
範例
有三個學生{小昂,小王,大名}
試不使用雙層迴圈來取出他們的資訊並列出
結構
測試程式
結果
簡單實作自己的SelectMany
作法
參考 Source Code
Thank you!
You can find me on
若有謬誤 , 煩請告知 , 新手發帖請多包涵
- The image file may be corrupted
- The server hosting the image is unavailable
- The image path is incorrect
- The image format is not supported
Learn More →- The image file may be corrupted
- The server hosting the image is unavailable
- The image path is incorrect
- The image format is not supported
Learn More →- The image file may be corrupted
- The server hosting the image is unavailable
- The image path is incorrect
- The image format is not supported
Learn More →- The image file may be corrupted
- The server hosting the image is unavailable
- The image path is incorrect
- The image format is not supported
Learn More →