This post originated from an RSS feed registered with .NET Buzz
by Tim Sneath.
Original Post: Write Console Apps with .NET
Feed Title: Tim Sneath's Blog
Feed URL: /msdnerror.htm?aspxerrorpath=/tims/Rss.aspx
Feed Description: Random mumblings on Microsoft, .NET, and other topics.
I've been really amused by how excited people are by the enhanced console support
in Whidbey. At our developer conference, there was a smattering of applause when Kieran
demonstrated a text-mode version of Space Invaders written entirely in managed
code (and that's saying something - whilst US audiences are generous with their applause
during sessions, we're a cynical lot over this side of the pond :-)
Whidbey introduces to the Console class the ability to change colour, reset the cursor
position, clear the screen, and even play sounds (any sound you like, so long as it's
"beep"). I find it rather ironic that it's taken nine versions of Visual Basic to
get to this high level of advancement (although there was of course the aberration
that was Visual Basic for DOS).
If you want this functionality right now, I created a little
sample for GotDotNet that uses .NET interop to call the underlying Windows API
to achieve similar effects. The library is called ConsoleEx, and it supports .NET
Framework 1.0 and 1.1. It's a good example of how to call into C APIs as well as hopefully
being useful in its own right. Since I've written it, it probably doesn't scale well
and is without doubt a poorer class design than the Whidbey one - the usual disclaimers
about lack of warranty apply here more than ever.
(Incidentally, if you're a registered Whidbey beta site, you can download the Space
Invaders sample from BetaPlace.)