久久久久久久av_日韩在线中文_看一级毛片视频_日本精品二区_成人深夜福利视频_武道仙尊动漫在线观看

    1. <i id='ozm4r'><tr id='ozm4r'><dt id='ozm4r'><q id='ozm4r'><span id='ozm4r'><b id='ozm4r'><form id='ozm4r'><ins id='ozm4r'></ins><ul id='ozm4r'></ul><sub id='ozm4r'></sub></form><legend id='ozm4r'></legend><bdo id='ozm4r'><pre id='ozm4r'><center id='ozm4r'></center></pre></bdo></b><th id='ozm4r'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='ozm4r'><tfoot id='ozm4r'></tfoot><dl id='ozm4r'><fieldset id='ozm4r'></fieldset></dl></div>
    2. <legend id='ozm4r'><style id='ozm4r'><dir id='ozm4r'><q id='ozm4r'></q></dir></style></legend>

      <tfoot id='ozm4r'></tfoot>
      • <bdo id='ozm4r'></bdo><ul id='ozm4r'></ul>

      <small id='ozm4r'></small><noframes id='ozm4r'>

    3. 一些有助于理解“產(chǎn)量".

      Some help understanding quot;yieldquot;(一些有助于理解“產(chǎn)量.)
        <bdo id='5S1zg'></bdo><ul id='5S1zg'></ul>

                <tbody id='5S1zg'></tbody>

              <tfoot id='5S1zg'></tfoot>

            • <legend id='5S1zg'><style id='5S1zg'><dir id='5S1zg'><q id='5S1zg'></q></dir></style></legend>

              <small id='5S1zg'></small><noframes id='5S1zg'>

              <i id='5S1zg'><tr id='5S1zg'><dt id='5S1zg'><q id='5S1zg'><span id='5S1zg'><b id='5S1zg'><form id='5S1zg'><ins id='5S1zg'></ins><ul id='5S1zg'></ul><sub id='5S1zg'></sub></form><legend id='5S1zg'></legend><bdo id='5S1zg'><pre id='5S1zg'><center id='5S1zg'></center></pre></bdo></b><th id='5S1zg'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='5S1zg'><tfoot id='5S1zg'></tfoot><dl id='5S1zg'><fieldset id='5S1zg'></fieldset></dl></div>
              • 本文介紹了一些有助于理解“產(chǎn)量".的處理方法,對(duì)大家解決問(wèn)題具有一定的參考價(jià)值,需要的朋友們下面隨著小編來(lái)一起學(xué)習(xí)吧!

                問(wèn)題描述

                在我不斷追求減少吸吮的過(guò)程中,我試圖理解yield"語(yǔ)句,但我一直遇到同樣的錯(cuò)誤.

                In my everlasting quest to suck less I'm trying to understand the "yield" statement, but I keep encountering the same error.

                [someMethod] 的主體不能是迭代器塊,因?yàn)?System.Collections.Generic.List<AClass>' 不是迭代器接口類(lèi)型.

                The body of [someMethod] cannot be an iterator block because 'System.Collections.Generic.List< AClass>' is not an iterator interface type.

                這是我卡住的代碼:

                foreach (XElement header in headersXml.Root.Elements()){
                    yield return (ParseHeader(header));                
                }
                

                我做錯(cuò)了什么?我不能在迭代器中使用 yield 嗎?那有什么意義呢?在此示例中,它表示 List<ProductMixHeader> 不是迭代器接口類(lèi)型.ProductMixHeader 是一個(gè)自定義類(lèi),但我想 List 是一個(gè)迭代器接口類(lèi)型,不是嗎?

                What am I doing wrong? Can't I use yield in an iterator? Then what's the point? In this example it said that List<ProductMixHeader> is not an iterator interface type. ProductMixHeader is a custom class, but I imagine List is an iterator interface type, no?

                --編輯--
                感謝所有快速回答.
                我知道這個(gè)問(wèn)題并不是那么新鮮,并且不斷出現(xiàn)相同的資源.
                原來(lái)我在想我可以返回 List<AClass> 作為返回類(lèi)型,但由于 List<T> 不是惰性的,它不能.將我的返回類(lèi)型更改為 IEnumerable<T> 解決了問(wèn)題:D

                --Edit--
                Thanks for all the quick answers.
                I know this question isn't all that new and the same resources keep popping up.
                It turned out I was thinking I could return List<AClass> as a return type, but since List<T> isn't lazy, it cannot. Changing my return type to IEnumerable<T> solved the problem :D

                一個(gè)有點(diǎn)相關(guān)的問(wèn)題(不值得打開(kāi)一個(gè)新線程):如果我確定 99% 的情況我要去,是否值得將 IEnumerable<T> 作為返回類(lèi)型去 .ToList() 反正?性能影響是什么?

                A somewhat related question (not worth opening a new thread): is it worth giving IEnumerable<T> as a return type if I'm sure that 99% of the cases I'm going to go .ToList() anyway? What will the performance implications be?

                推薦答案

                使用yield return的方法必須聲明為返回以下兩個(gè)接口之一:

                A method using yield return must be declared as returning one of the following two interfaces:

                IEnumerable<SomethingAppropriate>
                IEnumerator<SomethingApropriate>
                

                (感謝 喬恩 和 Marc 用于指出 IEnumerator)

                (thanks Jon and Marc for pointing out IEnumerator)

                例子:

                public IEnumerable<AClass> YourMethod()
                {
                    foreach (XElement header in headersXml.Root.Elements())
                    {
                        yield return (ParseHeader(header));                
                    }
                }
                

                yield 是一個(gè)懶惰的數(shù)據(jù)生產(chǎn)者,僅在檢索到第一個(gè)項(xiàng)目后才生成另一個(gè)項(xiàng)目,而返回列表將一次性返回所有內(nèi)容.

                yield is a lazy producer of data, only producing another item after the first has been retrieved, whereas returning a list will return everything in one go.

                所以有區(qū)別,需要正確聲明方法.

                So there is a difference, and you need to declare the method correctly.

                有關(guān)更多信息,請(qǐng)閱讀 Jon 的答案,其中包含一些非常有用的鏈接.

                For more information, read Jon's answer here, which contains some very useful links.

                這篇關(guān)于一些有助于理解“產(chǎn)量".的文章就介紹到這了,希望我們推薦的答案對(duì)大家有所幫助,也希望大家多多支持html5模板網(wǎng)!

                【網(wǎng)站聲明】本站部分內(nèi)容來(lái)源于互聯(lián)網(wǎng),旨在幫助大家更快的解決問(wèn)題,如果有圖片或者內(nèi)容侵犯了您的權(quán)益,請(qǐng)聯(lián)系我們刪除處理,感謝您的支持!

                相關(guān)文檔推薦

                Ignore whitespace while reading XML(讀取 XML 時(shí)忽略空格)
                XML to LINQ with Checking Null Elements(帶有檢查空元素的 XML 到 LINQ)
                Reading XML with unclosed tags in C#(在 C# 中讀取帶有未閉合標(biāo)簽的 XML)
                Parsing tables, cells with Html agility in C#(在 C# 中使用 Html 敏捷性解析表格、單元格)
                delete element from xml using LINQ(使用 LINQ 從 xml 中刪除元素)
                Parse malformed XML(解析格式錯(cuò)誤的 XML)
              • <tfoot id='bOwua'></tfoot>
                  <bdo id='bOwua'></bdo><ul id='bOwua'></ul>

                    1. <small id='bOwua'></small><noframes id='bOwua'>

                        <tbody id='bOwua'></tbody>
                      • <legend id='bOwua'><style id='bOwua'><dir id='bOwua'><q id='bOwua'></q></dir></style></legend>

                          <i id='bOwua'><tr id='bOwua'><dt id='bOwua'><q id='bOwua'><span id='bOwua'><b id='bOwua'><form id='bOwua'><ins id='bOwua'></ins><ul id='bOwua'></ul><sub id='bOwua'></sub></form><legend id='bOwua'></legend><bdo id='bOwua'><pre id='bOwua'><center id='bOwua'></center></pre></bdo></b><th id='bOwua'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='bOwua'><tfoot id='bOwua'></tfoot><dl id='bOwua'><fieldset id='bOwua'></fieldset></dl></div>
                          主站蜘蛛池模板: 久久久成人精品 | 国产精品久久久久久模特 | 久久最新精品视频 | 国产在线精品一区二区 | 欧美在线 | 日韩欧美国产精品一区二区 | 国产在线视频一区二区董小宛性色 | 午夜av电影| 天天弄天天操 | 欧美精品网| av大片 | 一区二区三区四区电影 | 中文字幕免费在线 | 国产成人精品久久二区二区91 | 一区二区三区视频在线观看 | 国产精品国产成人国产三级 | 在线播放91 | 成人激情视频免费在线观看 | 国产精品久久久久久久三级 | 欧美日韩亚洲一区二区 | 日日爱视频 | 狠狠干美女 | 日韩成人免费视频 | 国产精品a久久久久 | 日韩手机在线看片 | 国产精品成人一区二区三区 | 亚洲视频国产视频 | 国产一区二区三区高清 | 国际精品鲁一鲁一区二区小说 | 伊人网站 | 日本视频在线播放 | 久久99精品视频 | 久久黄视频 | 欧美精品在线一区二区三区 | 日日噜噜夜夜爽爽狠狠 | 夜夜精品浪潮av一区二区三区 | 欧美不卡| 婷婷成人在线 | 国产激情免费视频 | 一级片在线观看 | 国产黄色在线观看 |