O'Reilly logo

C# 5.0 Unleashed by Bart De Smet

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

The Empty Statement

To ease into the subject of statements gradually, let’s start with the most mind-blowing of all: the empty statement. Written as a simple semicolon by itself, it’s rarely useful. One of the only cases where this comes in handy is when you’re writing some kind of “message pump,” a loop that calls some processing method until it returns false to indicate no further messages are to be handled:

while (ProcessMessage())    ;

I predict most readers won’t ever have to write such a loop anymore—we’re well beyond the manual message pumping required in classic Win32—but it’s good to know about its existence in case you encounter this kind of code. In fact, you could eliminate the use of the preceding empty statement by using an empty ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required