Write to console with TextWriter in CSharp

Description

The following code shows how to write to console with TextWriter.

Example


// w w  w  .  j a  va 2  s .  co m
using System;
using System.Collections.Generic;
using System.Collections.Specialized;
using System.IO;
using System.IO.Compression;
using System.Runtime.InteropServices;
using System.Text;

public class MainClass
{
    public static void Main()
    {
        using (TextWriter tw = Console.Out)
        {
            tw.Write(302.30m); 
            tw.Write("str"); 
            tw.Write(true); 
            tw.WriteLine('.');
        }
    }
}

The code above generates the following result.





















Home »
  C# Tutorial »
    IO »




File Attribute
File Security
Directory Attribute
Directory Recursive
Binary File
Text Field
Buffered IO
Create Copy Delete Move
CSV
Drive
File System Watcher
Isolated Storage
MemoryStream
Serialize
Zip