Quantcast
Channel: Planet Object Pascal
Viewing all articles
Browse latest Browse all 1725

The Wiert Corner - irregular stream of stuff: jpluimers

$
0
0

Peter Leslie Morris asked if Delphi already incorporates the `yield` keyword that C# had introduced in C# 2.

Delphi doesn’t, but for the people interested what it does in C#:

Basically `yield` is syntactic sugar to make it a lot easier to write methods that return enumerators of some sort.

It delays (hence the yield keyword) execution until the enumerator as actually being used.

It is one of the hardest C# things to master (it is the most complicated transformation in the compiler, followed by anonymous methods - well maybe with the exception of async/await), but it can be very useful.

VB.NET doesn’t have it either, but has iterator blocks.

Some start posts on yield:

–jeroen


Filed under: .NET, .NET 2.0, .NET 3.0, .NET 3.5, .NET 4.0, .NET 4.5, C#, C# 2.0, C# 3.0, C# 4.0, C# 5.0, Delphi, Development, Software Development

Viewing all articles
Browse latest Browse all 1725

Trending Articles