Building .NET Console Applications in C#

Learn how to create well-designed, fully-featured .NET Console applications.
Course info
Rating
(149)
Level
Intermediate
Updated
Mar 20, 2014
Duration
2h 10m
Table of contents
Handling Input and Output
Command Line Arguments
Manipulating the Console Window
Architecting Console Applications
Description
Course info
Rating
(149)
Level
Intermediate
Updated
Mar 20, 2014
Duration
2h 10m
Description

Learn how to create well-designed .NET console applications and how to manipulate the console window, parse command line arguments, and handle input and output. By the end of this course you'll be developing maintainable applications that take full advantage of .NET console application capabilities.

About the author
About the author

With over 15 years experience, Jason Roberts is a Microsoft .NET MVP, freelance developer, and author.

More from the author
Mocking with Moq and NUnit
Intermediate
1h 53m
Feb 22, 2019
Introduction to .NET Testing with NUnit 3
Intermediate
2h 6m
Dec 17, 2018
More courses by Jason Roberts
Section Introduction Transcripts
Section Introduction Transcripts

Handling Input and Output
Hi. Welcome to Building. NET Console Applications in C#. I'm Jason Roberts from Pluralsight. In this course we're going to learn how to create well-designed Console applications, how to manipulate the Console window, how to effectively parse command-line arguments, and handle input and output. By the end of this course you'll be able to develop maintainable applications that take full advantage of the. NET Console application capabilities. In this first module on input and output, we'll be learning how to write to the Console window, and how to read lines of text input from our users. We'll also learn how to react to individual keystrokes and check the status of the num lock and caps lock keys. We'll see how we can redirect the standard input and output streams in Console applications, and how to handle CTRL-C, which ordinarily will exit our application. Finally, we'll take a look at how our Console applications can work at the command line when we pipe content to them. Hi. Welcome to Building. NET Console Applications in C#. I'm Jason Roberts from Pluralsight. In this course we're going to learn how to create well-designed Console applications, how to manipulate the Console window, how to effectively parse command-line arguments, and handle input and output. By the end of this course you'll be able to develop maintainable applications that take full advantage of the. NET Console application capabilities. In this first module on input and output, we'll be learning how to write to the Console window, and how to read lines of text input from our users. We'll also learn how to react to individual keystrokes and check the status of the num lock and caps lock keys. We'll see how we can redirect the standard input and output streams in Console applications, and how to handle CTRL-C, which ordinarily will exit our application. Finally, we'll take a look at how our Console applications can work at the command line when we pipe content to them.

Command Line Arguments
Hi. Welcome back to Module 2, Command Line Arguments. In this module, we're going to see how we can read command line arguments from our users, and how quotation marks and backslashes affect what get passed from the command line to our. NET Console application. We'll also see how we can set command line arguments when we're using the debugger in Visual Studio so we can simply hit F5 rather than executing the application from the command line. We'll then pause for a moment to consider some of the complexities of argument parsing that might not be apparent at first glance. We'll then see how the Command Line Parser Library helps to address some of these hidden complexities and means that we don't have to reinvent the wheel when it comes to command line parsing.

Manipulating the Console Window
Welcome back to Module 3, Manipulating the Console Window. In this module, we'll see how we can change the Console window's title to change it from the default to something we specify. We'll see how we can manipulate the Console width and height, and how we can set the foreground colors that are in use when we write text to the Console window. We'll see how we can create a busy indicator animation if we're processing a list of items that could take some time. And also how we can generate sounds using the Console class. Finally, we'll look at how we can move content from area of our screen to another area.

Architecting Console Applications
Hi. Welcome back to this final module, Architecting Console Applications. Up until this point in this course, we've pretty much just been putting all our code in the main method of our program class and while this is fine for demo purposes, in real-world situations we don't really want to do this. In this module, we're going to look at some ways we can create better architected Console applications to allow us to better segregate the parts of the application, and also reduce the amount of boilerplate code that we need to write. So, first off in this module, we're going to quickly review why we don't want to put all of our code in the Main method in our Console application. We're going to get a brief overview of the template method pattern, which we'll be using later on in the module. We'll see how we can create a base class containing this template method idea and then see how we can actually use this base class in a Console application. We'll then see how we can use this pattern with inputs other than the Standard Console keyboard input. We'll see that once we've created one concrete processor from our base class containing this template method how we can go and subclass this further to create variations of existing processes. And finally, we'll look at an alternative implementation that we means we don't have to create subclasses and what this can mean for code reuse.