Click here to Skip to main content
15,949,686 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
Im getting an error converting this code. Please help cause in vb.net there is no yeild
VB
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

how can I change that?
Posted
Comments
Sergey Alexandrovich Kryukov 14-Feb-12 0:02am    
What is the purpose of this code. Are you really implementing the iterator behavior? It looks like you simply returning the IEnumerable, but in this case RoomUsers.Values is already the result you need.

Do you really understand what is "yield" for?
--SA

1 solution

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[^]
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900