VB.NET 中的迭代器模式(C# 将使用 yield!) [英] Iterator pattern in VB.NET (C# would use yield!)
本文介绍了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 现在支持使用异步 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屋!
查看全文