C# Tutorials and offshore development in India
    Tutorials   Resources   Forum   Reviews   Communities   Interview   Jobs   Projects   Training   Your Ad Here    
Silverlight Games | Mentor | Code Converter | Articles | Code Factory | Computer Jokes | Members | Peer Appraisal | IT Companies | Bookmarks | Polls | Revenue Sharing | Lobby | Gift Shop |


Prizes & Awards
My Profile



Active Members
TodayLast 7 Days more...






Resources » Articles » .NET Framework »

The Power and Prowess of Console Applications and Enhancing it with .NET Framework 2.0


Posted Date: 17 Sep 2007    Resource Type: Articles    Category: .NET Framework
Author: Vasudevan Deepak KumarMember Level: Diamond    
Rating: 1 out of 5Points: 10



Introduction


To start learning a new programming language, following the C++ book style, the first and foremost application that we write is


cout << "Hello World";


We have been religiously inheriting this custom through Java and to C# via the essence of Console Applications.

java:



System.out.println ("Hello World");


C#:



System.Console.WriteLine ("Hello World");


A simpler console application lays the greater foundation for a powerful and rewarding journey through the programming language. Let us in brief see about the essence of these console applications and how .NET Framework BCL richly complements console applications.

The Inspiration


This article was actually inspired from a discussion board question where a beginner had just vehemently violated the message board netiquette about a sample code snippet which an expert had provided with great magnanimity. Fuelling it, he/she had also scrapped base about console applications. I just thought I would take this opportunity to initiate the efforts in clearing the myth clouding about the console applications.

Simpler and Stronger


1) Console applications are a stronger support to even a full-fledged application frameworks. For example consider an application like 'Windows Service' project in C#. By default, you can not run a Windows Service project but you can only attach to the running process to debug the same. But there is an easy workaround using the Visual Studio IDE. With the other classes that are used in the same way, the launching class (Service.cs) can be excluded from the project while debugging and a sample (StartupConsole.cs) can be used. This can emulate threads from within a sample Console application facilitating easier peek of the startup configuration of the Windows service.

2) Console applications are a very good applications to provide code snippets for articles since they are easier to visualize, compile for the casual article viewer also.

3) Console applications are lighter and supported by the heart library of the framework. .NET Framework supports Console right in System namespace (rooted to the core) and Java supports in its java.lang.

4) There is also a good business potential of console applications. There are still a lot of retail shops who prefer a commandline console based data entry approach for billing and other things. We can use the richness of Console applications there.

Simpler and Sweet Extensions to Console in .NET Framework 2.0


The console applications have grown more powerful at least with respect to .NET Framework 2.0. I first thought I would provide a Class documentation for the same in http://www.dotnetspider.com/ but then I chose to include it as part of this article context for better reach.

A few of the new namespaces that add color and brightness to to the otherwise dark console are:

1) BackgroundColor
2) ConsoleColor enumeration
3) CapsLock (To detect whether CAPSLock is on or off in just a jiffy)
4) NumberLock (To detect whether NumberLock is on or off in just a jiffy)
5) Clear (To clear the console display. Our class CLS command of DOS. No more P/Invoke :))
6) A host of other Window manipulation utilities like SetWindowPosition, SetWindowSize
7) ReadKey -- Equivalent to provide 'Press any key to continue in C#' without RETURN. However, for older .NET Framework versions, I have a workaround in my other article here: http://www.codeproject.com/useritems/PressAnyKeyToContinue.asp

P.S.: A significant amount of them are also available in .NET Framework 1.1 albeit you have to delve into P/Invoke Library for the same. However, I would suggest ManiB's article on CodeProject which hides this P/Invoke management from your core application logic. Check it out here: http://www.codeproject.com/cs/library/csconsolelibrary.asp

Musical Fest in Console namespace


A few of you who might have worked in either GWBasic or QBasic would have known about the three powerful commands there:

BEEP: Produces a short shirk beep from the computer speaker
SOUND freq, duration: Produces sound of frequency freq for dur milliseconds
PLAY Plays a musical note from your computer speaker.

I was just wondering whether this is not going to be supported at all after QBasic from Visual Basic onwards. It is a good news that .NET Framework 2.0 Base Class Library supports System.Console.Beep equivalent to SOUND in QBasic. Check out the MSDN documentation for the song 'Mary had a little lamb ...'

Sometime back when I started venturing into this musical power, I posted a question in one of the forums and I even got lot of library references as responses. I would like to give the permalink of the discussion thread for readers reference here: http://www.codeproject.com/script/comments/forums.asp?msg=2213024&forumid=1650#xx2213024xx

Summary


This is just an introductory primer article on the power and potential of console utilities in any programming language at least with particular emphasis to .NET Framework 2.0. Let me know as feedback comments to this article on various other additions you would have observed or programmed for the benefit of other readers.



Responses


No responses found. Be the first to respond and make money from revenue sharing program.

Feedbacks      
Popular Tags   What are tags ?   Search Tags  
Sign In to add tags.
(No tags found.)

Post Feedback


This is a strictly moderated forum. Only approved messages will appear in the site. Please use 'Spell Check' in Google toolbar before you submit.
You must Sign In to post a response.
Next Resource: Working with Assembly
Previous Resource: Typical DotNet Interviewer Topics
Return to Discussion Resource Index
Post New Resource
Category: .NET Framework


Post resources and earn money!
 
More Resources



dotNet Slackers

About Us    Contact Us    Privacy Policy    Terms Of Use