Introduction
The purpose of this example is to provide people with a simple class library that should be sufficient
to handle all of your console IO needs. I started off calling it Console IO but now that I'm finished with it I
realize there is no real output involved in this class library and its just Input and parsing.
Background
As a computer science major I first started off with java since it's what is used at the university I attend. For most people understanding
simple programming concepts are difficult enough so a class is usually provided to new programmers for handling console input. Well the first class that
I had to use which was used as a reference for this class was SavitchIn which was provided with our java text book (Because everyone knows Console Input in java is
ridiculous).
As I Started using c# I realized that even though console IO is very easy its not obvious what to do with this information
once you have read it from the console so I felt
I'd provide this class for anyone starting off their programming experience with c#.
There are very few concepts that the beginning programmer needs to know in .net to be able to use this class.
- You must have an understanding of the simple data types.
- While it is not necessary exception handling is useful since some of the methods can possibly pass an exception up the stack.
Since the class is very simple there is no need for a class diagram for it. There is a single namespace called ConIO
. Within this
namespace resides one class called ConInput
which is properly named. This is a class containing all static methods for reading input.
All of the methods have proper documentation and work properly with Intellisense. The only thing that is needed is to reference the library in any of your projects
and you are good to go.
The solution is setup so that the files for the demo program and for the class are in the same solution. The demo program should be set as
the start up project. If it is not just right click on the project for ConInputTest and click set as startup project.
Using the code
using ConIO;
string input = ConInput.ReadLine();
UInt16 number = ConInput.ReadLineUInt16();
Points of Interest
I know this topic is very basic but I intended this to be part of a series of sample programs to showcase beginning programming concepts
in c#. I would greatly appreciate any feedback on this class no matter how simple it may seem.
History
- Version 1.0 Initial Release