NGWS SDK Documentation  

This is preliminary documentation and subject to change.
To comment on this topic, please send us email at ngwssdk@microsoft.com. Thanks!

Console Class

Provides access to the standard input, standard output, and standard error streams. These streams are represented by Console.In, Console.Out, and Console.Error, respectively. They can be redirected via the SetIn, SetOut, and SetError methods.

The read methods provided by this class read from Console.In. They are provided as an alternative to directly invoking them on Console.In that is a StreamReader.

The write methods provided by this class write to Console.Out. They are provided as an alternative to directly invoking them on Console.Out that is a StreamWriter. Console.Error is also a StreamWriter.

Object
   Console

[Visual Basic]
NotInheritable Public Class Console
[C#]
public sealed class Console
[C++]
public __gc __sealed class Console
[JScript]
public class Console

Remarks

[To be supplied.]

Requirements

Namespace: System

Assembly: mscorlib.dll

Example

This Managed C++ code sample demonstrates how to read from and write to the standard input and output streams. Note that these streams can be redirected using the SetIn and SetOut methods.

[C++]
#import <mscorlib.dll>
void main()
{
  Console::Write(L"Hola ");
  Console::WriteLine(L"Mundo!");
  Console::WriteLine(L"What is your name: ");
  String *name = Console::ReadLine();
  Console::Write(L"Buenos Dias, ");
  Console::Write(name);
  Console::WriteLine(L"!");
};

This Managed C++ code sample demonstrates how TextReader and TextWriter objects can be synchronized using the Synchronize method provided by both of these classes.

[C++]
#import <mscorlib.dll&rt;
using namespace IO;

#define NULL 0

class console
{
    public:
    static void Loop()
    {
   while (1) {
       Console::WriteLine(L"aaaaaaaaaaaaaaaaaaaaaaaa");
       Thread::Sleep(0);
   }
    }
  
    static void LoopB()
    {
   while (1) {
       Console::WriteLine(L"bbbbbbbbbbbbbbbbbbbbbbbb");
       Thread::Sleep(5);
   }
    }
    static void Test()
    {
   Console::WriteLine(L"Hi there");
   ThreadStart *ts = new ThreadStart(NULL, &console::Loop);
   ThreadStart *tsb = new ThreadStart(NULL, &console::LoopB);
   (new Thread(ts))-&rt;Start();
   (new Thread(tsb))-&rt;Start();
    }
};

void main()
{
    // To synchronize the console, use these two calls:
  
    TextWriter *t = Console::Out;
    Console::SetOut(t);
    console::Test();
};

See Also

Console Members | System Namespace