|
August 20, 2002 Using the System.Console Class Tips: August 2002
Yehuda Shiran, Ph.D.
|
|
The class System.Console is slightly more powerful than the print statement. Its methods feature display options that are not supported by the print statement. The WriteLine() method mimics the print statement. The Write() method displays a string without appending a newline character. The ReadLine() method reads from the command line, starting from the end of the previous output string, and ending at the end of the line. Having both read and write functionalities enables you to create a dialog with the user.
To use classes from the .NET framework, such as the
The following JScript .NET script shows how to print messages with the
The program defines a class, HelloWorld, with two methods: the constructor HelloWorld() and TypeHello(). Each method prints one string. The constructor prints the message "Object Constructed" when an object of type HelloWorld is constructed. The TypeHello() method prints the message "Hello World". You can compile this program with the jsc compiler. When you run the generated executable (the output of the compiler), you'll see the two print messages.To learn more about JScript .NET and ASP.NET, go to Column 116, JScript .NET, Part IX: Displaying Information.
People who read this tip also read these tips: Look for similar tips by subject: |