I have seen this syntax in MSDN: yield break, but I don’t know what it does. Does anyone know?
I have seen this syntax in MSDN: yield break , but I don’t know
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
It specifies that an iterator has come to an end. You can think of
yield breakas areturnstatement which does not return a value.For example, if you define a function as an iterator, the body of the function may look like this:
Note that after the loop has completed all its cycles, the last line gets executed and you will see the message in your console app.
Or like this with
yield break:In this case the last statement is never executed because we left the function early.