VB.NET中的迭代器模式(C#会使用yield!) [英] Iterator pattern in VB.NET (C# would use yield!)

查看:117
本文介绍了VB.NET中的迭代器模式(C#会使用yield!)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何在 VB.NET 中实现迭代器模式,该模式没有 yield 关键字?

How do implement the iterator pattern in VB.NET, which does not have the yield keyword?

推荐答案

VS 2010 SP1现在支持使用Async CTP,请参阅:MSDN上的迭代器(C#和Visual Basic)下载Visual Studio Async CTP(版本3)

This is now supported in VS 2010 SP1, with the Async CTP, see: Iterators (C# and Visual Basic) on MSDN and download Visual Studio Async CTP (Version 3).

这样的代码,作品:

Private Iterator Function SomeNumbers() As IEnumerable
    ' Use multiple yield statements.
    Yield 3
    Yield 5
    Yield 8
End Function

这篇关于VB.NET中的迭代器模式(C#会使用yield!)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆