|
The yield return op code is one of my favorites in its neatness ( and,
I think, is unique to C# ). Here is an extension method which returns
an IEnumerable interface to a sequence of Int which is parsed from a
string of comma separated numbers:
public static IEnumerable<int?> ParseLine(this string InLine)
Steve: The yield statement goes back a long time. I couldn't tell you
when a programming language first had that kind of feature, but C#
definitely was not the first. Another commonly used modern language
with
yield is Python. But in Python, I wouldn't bother using yield for that
kind of thing. To convert a comma separated string of numbers into a
list, I'd code something like this:
As an Amazon Associate we earn from qualifying purchases.
This mailing list archive is Copyright 1997-2024 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].
Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.