CHAPTER 3 C# LANGUAGE FUNDAMENTALS 73 class (Free web design)

CHAPTER 3 C# LANGUAGE FUNDAMENTALS 73 class HelloApp { public static int Main(string[] args) { HelloClass c1 = new HelloClass(”Hey there…”); c1.PrintMessage(); … } } Source Code The HelloClass project is located under the Chapter 3 subdirectory. The System.Console Class Many of the example applications created over the course of these first few chapters make extensive use of the System.Console class. While a console user interface (CUI) is not as enticing as aWindows or web UI, restricting the early examples to a CUI will allow us to keep focused on the concepts under examination, rather than dealing with the complexities of building GUIs. As its name implies, the Console class encapsulates input, output, and error stream manipulations for console-based applications. With the release of .NET 2.0, the Console type has been enhanced with additional functionality. Table 3-2 lists some (but not all) new members of interest. Table 3-2. Select .NET 2.0 Specific Members of System.Console Member Meaning in Life BackgroundColor These properties set the background/foreground colors for the current ForegroundColor output. They may be assigned any member of the ConsoleColor enumeration. BufferHeight These properties control the height/width of the console s buffer area. BufferWidth Clear() This method clears the buffer and console display area. Title This property sets the title of the current console. WindowHeight These properties control the dimensions of the console in relation to WindowWidth the established buffer. WindowTop WindowLeft Basic Input and Output with the Console Class In addition to the members in Table 3-2, the Console type defines a set of methods to capture input and output, all of which are defined as static and are therefore called at the class level. As you have seen, WriteLine() pumps a text string (including a carriage return) to the output stream. The Write() method pumps text to the output stream without a carriage return. ReadLine() allows you to receive information from the input stream up until the carriage return, while Read() is used to capture a single character from the input stream. To illustrate basic I/O using the Console class, consider the following Main() method, which prompts the user for some bits of information and echoes each item to the standard output stream. Figure 3-5 shows a test run.
Note: If you are looking for cheap and reliable webhost to host and run your mysql application check mysql web server services.

Leave a Reply