.net没有收益我不知道该怎么办 [英] .net doesnt have a yield I dont know what to do

查看:86
本文介绍了.net没有收益我不知道该怎么办的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在转换此代码时遇到错误.请帮助,因为vb.net中没有yeild

Im getting an error converting this code. Please help cause in vb.net there is no yeild

Public Function GetRoomUsersNames() As IEnumerable(Of String)
            ExpireUsers(userChatRoomSessionTimeout)
            For Each key As Object In RoomUsers.Keys
               yield Return Me.RoomUsers(key.ToString()).UserName
            Next

        End Function


推荐答案

Yield是语法糖.在幕后,它返回一个IEnumerator实例,该实例处理回调到您的函数中.要进行惰性枚举,必须自己在VB中实现.

开始阅读的时间:立即在VB中使用迭代器 [ ^ ]
Yield is syntactic sugar. Behind the scenes it returns an IEnumerator instance that handles the callbacks into your function. To do the lazy enumeration, you have to implement it yourself in VB.

Time to start reading: Use Iterators in VB Now[^]


这篇关于.net没有收益我不知道该怎么办的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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